# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
877776 | LucaIlie | Council (JOI23_council) | C++17 | 4049 ms | 11636 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5;
const int MAX_M = 20;
struct aa {
int x, y;
void operator += ( const aa &a ) {
if ( x == -1 ) {
x = a.x;
y = a.y;
} else if ( y == -1 )
y = a.x;
}
};
aa countVc[1 << MAX_M];
int vote[MAX_N], pro[MAX_M];
int main() {
int n, m;
cin >> n >> m;
for ( int mask = 0; mask < (1 << m); mask++ )
countVc[mask] = { -1, -1 };
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]] += { i, -1 };
}
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].x != -1 && (countVc[vc].x != i || (countVc[vc].y != -1 && countVc[vc].y != i)) )
maxAp = max( maxAp, ap + __builtin_popcount( mask ) );
}
cout << maxAp << "\n";
}
return 0;
}
컴파일 시 표준 에러 (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... |