# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
877633 | LucaIlie | Council (JOI23_council) | C++17 | 1 ms | 2396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 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 );
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;
}
컴파일 시 표준 에러 (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... |