Submission #953479

#TimeUsernameProblemLanguageResultExecution timeMemory
953479weakweakweakCouncil (JOI23_council)C++17
16 / 100
4027 ms2784 KiB
//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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...