# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
236722 | VEGAnn | Izbori (COCI17_izbori) | C++14 | 19 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int oo = int(2e9);
bool mrk[N];
int n, m, k, ans = oo, kol[N], per[N][N];
int who(int mask){
fill(kol, kol + m, 0);
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++)
if (!(mask & (1 << j))) {
kol[per[i][j]]++;
break;
}
}
int mx = -1;
for (int i = 0; i < m; i++)
mx = max(mx, kol[i]);
for (int i = 0; i < m; i++)
if (mx == kol[i])
return i;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m >> k;
k--;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
cin >> per[i][j];
per[i][j]--;
}
cout << who(0) + 1 << '\n';
for (int mask = 0; mask < (1 << m) - 1; mask++)
if (who(mask) == k)
ans = min(ans, __builtin_popcount(mask));
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |