This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//target : 16pts
#include <bits/stdc++.h>
using namespace std;
int cnt[21] = {0};
int n, k, a[310000] = {0};
int main () {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
for (int j = 0, b; j < k; j++) {
cin >> b;
cnt[j] += b;
a[i] += (1 << j) * b;
}
}
int half = (n) / 2;
for (int i = 1; i <= n; i++) {
int stable = 0;
int nonstable = 0;
for (int j = 0; j < k; j++) {
if (a[i] & (1 << j)) cnt[j]--;
if (cnt[j] >= half + 1) stable += (1 << j);
else if (cnt[j] == half) nonstable += (1 << j);
}
int res = 0;
for (int j = 1; j <= n; j++) {
if (j == i) continue;
int z = a[j] & nonstable;
res = max(res, __builtin_popcount(nonstable) - __builtin_popcount(z));
}
res += __builtin_popcount(stable);
cout << res << '\n';
for (int j = 0; j < k; j++) if (a[i] & (1 << j)) cnt[j]++;
}
return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |