From a4c6e79f9920cc5c09055f0ccc061b93acb7060b Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Mon, 15 Nov 2021 13:21:42 +0800 Subject: [PATCH] CF1598B Groups R62650450 --- Luogu/CF1598B/CF1598B.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Luogu/CF1598B/CF1598B.cpp diff --git a/Luogu/CF1598B/CF1598B.cpp b/Luogu/CF1598B/CF1598B.cpp new file mode 100644 index 00000000..dbee78b0 --- /dev/null +++ b/Luogu/CF1598B/CF1598B.cpp @@ -0,0 +1,38 @@ +#include + +using namespace std; + +int t, n, cnt, l, r, a[1005][6]; +bool flag; + +int main() { + cin >> t; + while (t--) { + flag = false; + cin >> n; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= 5; j++) { + cin >> a[i][j]; + } + } + for (int i = 1; i <= 5; i++) { + for (int j = i + 1; j <= 5; j++) { + cnt = l = r = 0; + for (int k = 1; k <= n; k++) { + if (a[k][i] == 1 && a[k][j] == 1) { + cnt++; + } else { + l += a[k][i]; + r += a[k][j]; + } + } + if (cnt + l + r == n && l <= n / 2 && r <= n / 2) { + flag = true; + break; + } + } + } + cout << (flag ? "Yes" : "No") << endl; + } + return 0; +}