Submission #739640

#TimeUsernameProblemLanguageResultExecution timeMemory
739640sidonCouncil (JOI23_council)C++17
78 / 100
4093 ms22432 KiB
#include <bits/stdc++.h> using namespace std; const int B = 10; array<int, 2> s[1<<B][1<<B][2]; int popcount[1<<B]; signed main() { cin.tie(0)->sync_with_stdio(0); for(int i = 0; i < (1<<B); ++i) popcount[i] = __builtin_popcount(i); int N, M; cin >> N >> M; int A[N] {}, c[M] {}; for(int i = 0; i < N; ++i) { for(int j = 0; j < M; ++j) { int v; cin >> v; A[i] |= v << j; c[j] += v; } int x = A[i] >> B; for(int j = 0; j < (1<<B); ++j) { int v = popcount[j] - popcount[A[i] & j]; if(v > s[x][j][0][0]) s[x][j][0] = {v, i}; if(v > s[x][j][1][0]) swap(s[x][j][0], s[x][j][1]); } } for(int i = 0; i < N; ++i) { int ans {}, ext {}, x {}; for(int j = 0; j < M; ++j) { int cur = c[j] - bool(A[i] & (1<<j)); if(cur == N / 2) x |= 1<<j; if(cur > N / 2) ++ext; } for(int j = 0; j < (1<<B); ++j) ans = max(ans, popcount[(x >> B)] - popcount[(x >> B) & j] + s[j][x & ((1<<B) - 1)][s[j][x & ((1<<B) - 1)][1][1] != i][0]); cout << ans + ext << '\n'; } }
#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...