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 : 41 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)-1 - 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 |
---|
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... |