# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
956684 | ZHIRDILBILDIZ | Council (JOI23_council) | C++14 | 757 ms | 12420 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
const int N = 3e5 + 1;
int n, m;
int w[N];
int cnt[20];
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i)
for (int j = 0; j < m; ++j) {
int x;
cin >> x;
w[i] ^= (1 << j) * x;
cnt[j] += x;
}
if (m <= 10) {
int ans[(1 << m)] = {};
int us[1 << m + 10] = {};
for (int i = 1; i <= n; ++i)
++us[w[i]];
for (int msk1 = 0; msk1 < (1 << m); ++msk1) {
if (!us[msk1])
continue;
for (int q = 0; q < m ; ++q)
if ((1 << q) & msk1)
--cnt[q];
for (int msk2 = 0; msk2 < (1 << m); ++msk2) {
if (!us[msk2] || msk2 == msk1 && us[msk2] == 1)
continue;
int now = 0;
for (int q = 0; q < m ; ++q)
if ((1 << q) & msk2) {
if (cnt[q] - 1 >= n >> 1)
++now;
} else {
if (cnt[q] >= n >> 1)
++now;
}
ans[msk1] = max(ans[msk1], now);
}
for (int q = 0; q < m ; ++q)
if ((1 << q) & msk1)
++cnt[q];
}
for (int i = 1; i <= n; ++i)
cout << ans[w[i]] << '\n';
return 0;
}
if (n <= 3000) {
for (int i = 1; i <= n; ++i) {
int ans = 0;
for (int q = 0; q < m ; ++q)
if ((1 << q) & w[i])
--cnt[q];
for (int j = 1; j <= n; ++j) {
if (i == j)
continue;
int now = 0;
for (int q = 0; q < m ; ++q)
if (((1 << q) & w[j])) {
if((cnt[q] - 1) >= n >> 1)
++now;
} else {
if(cnt[q] >= n >> 1)
++now;
}
ans = max(ans, now);
}
for (int q = 0; q < m ; ++q)
if ((1 << q) & w[i])
++cnt[q];
cout << ans << '\n';
}
return 0;
}
return 0;
}
Compilation message (stderr)
# | 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... |