# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40400 | szawinis | Izbori (COCI17_izbori) | C++14 | 33 ms | 776 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 101, M = 16;
int n, m, k, ans = INT_MAX, a[N][M], cnt[M];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> k;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) cin >> a[i][j];
++cnt[a[i][1]];
}
cout << max_element(cnt+1, cnt+m+1) - cnt << endl;
for(int mask = 0; mask < (1 << m) - 1; mask++) {
fill(cnt+1, cnt+m+1, 0);
for(int i = 1; i <= n; i++) {
int j = 1;
while(mask >> (a[i][j] - 1) & 1) ++j;
++cnt[a[i][j]];
}
if(max_element(cnt+1, cnt+m+1) - cnt == k) ans = min(__builtin_popcount(mask), ans);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |