//target : 16 pts
#include <bits/stdc++.h>
using namespace std;
int cnt[21] = {0};
int n, k, a[310000] = {0}, half;
void solve2() {
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 = ((1 << k) - a[j]) & nonstable;
res = max(res, __builtin_popcount(z));
}
res += __builtin_popcount(stable);
cout << res << '\n';
for (int j = 0; j < k; j++) if (a[i] & (1 << j)) cnt[j]++;
}
exit(0);
}
void solve4 () {
cout << "I'm blue da be di da be die.";
exit(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;
}
}
half = (n) / 2;
if (n <= 3000) {
solve2();
}
else solve4();
return 0;}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |