# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
877632 | 2023-11-23T11:30:06 Z | LucaIlie | Council (JOI23_council) | C++17 | 2 ms | 4700 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3e5; const int MAX_M = 20; int countVc[1 << MAX_M], ans[1 << MAX_M]; int vote[MAX_N], pro[MAX_M]; int main() { int n, m; cin >> n >> m; for ( int i = 0; i < n; i++ ) { for ( int b = 0; b < m; b++ ) { int x; cin >> x; vote[i] += (x << b); pro[b] += x; } countVc[vote[i]]++; } for ( int b = 0; b < m; b++ ) { for ( int mask = 0; mask < (1 << m); mask++ ) { if ( (mask >> b) & 1 ) countVc[mask] += countVc[mask - (1 << b)]; } } for ( int i = 0; i < n; i++ ) { vector<int> bits; int ap = 0, maskBits; for ( int b = 0; b < m; b++ ) { int x = pro[b] - ((vote[i] >> b) & 1); if ( x > n / 2 ) ap++; if ( x == n / 2 ) { bits.push_back( b ); maskBits += (1 << b); } } int maxAp = 0; if ( ans[maskBits] == 0 ) { for ( int mask = 0; mask < (1 << bits.size()); mask++ ) { int vc = (1 << m) - 1; for ( int b = 0; b < bits.size(); b++ ) { if ( (mask >> b) & 1 ) vc -= (1 << bits[b]); } if ( countVc[vc] >= 2 || (((vote[i] & vc) != vote[i]) && countVc[vc] >= 1) ) maxAp = max( maxAp, __builtin_popcount( mask ) ); } ans[maskBits] = maxAp + 1; } else maxAp = ans[maskBits] + 1; cout << ap + maxAp << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4700 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4700 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4696 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4696 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4696 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4696 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 4700 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |