Submission #1172479

#TimeUsernameProblemLanguageResultExecution timeMemory
1172479lopkusCouncil (JOI23_council)C++20
6 / 100
4094 ms49760 KiB
#include <bits/stdc++.h>+ signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; std::vector<std::vector<int>> a(n, std::vector<int>(m)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { std::cin >> a[i][j]; } } std::vector<int> cnt(m); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cnt[j] += a[i][j]; } } std::vector<int> c(n, 0); std::vector<int> ans(n, 0); std::vector<int> b(n, 0); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(a[i][j] == 0) { b[i] |= (1LL << j); } } } std::map<int,int> w; for(int i = 0; i < n; i++) { w[b[i]] += 1; } for(int x = 0; x < n; x++) { for(int i = 0; i < m; i++) { if(cnt[i] >= n / 2 + 2) { ans[x] += 1; continue; } if(cnt[i] < n / 2) { continue; } if(a[x][i] && cnt[i] == n / 2) { continue; } if(!a[x][i] && cnt[i] == n / 2 + 1) { ans[x] += 1; continue; } c[x] |= (1LL << i); } int to = 0; for(int f = 0; f < (1LL << m); f++) { if(!w[f]) { continue; } if(b[x] == f && w[f] == 1) { continue; } to = std::max(to, __builtin_popcount((f & c[x]))); } std::cout << ans[x] + to << "\n"; } }

Compilation message (stderr)

council.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>+
      |                         ^
#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...