# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
877629 | LucaIlie | Council (JOI23_council) | C++17 | 4022 ms | 13428 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>
using namespace std;
const int MAX_N = 3e5;
const int MAX_M = 20;
int countVc[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;
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 );
}
int maxAp = ap;
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, ap + __builtin_popcount( mask ) );
}
cout << maxAp << "\n";
}
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... |