# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98100 | dalgerok | Izbori (COCI17_izbori) | C++17 | 29 ms | 392 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;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
k -= 1;
int a[n][m], cnt[m];
memset(cnt, 0, sizeof(cnt));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> a[i][j];
a[i][j] -= 1;
}
cnt[a[i][0]] += 1;
}
cout << max_element(cnt, cnt + m) - cnt + 1 << "\n";
int ans = 2e9;
for(int mask = 0; mask + 1 < (1 << m); mask++){
memset(cnt, 0, sizeof(cnt));
for(int i = 0; i < n; i++){
int j = 0;
while((mask >> a[i][j]) & 1){
j += 1;
}
cnt[a[i][j]] += 1;
}
if(max_element(cnt, cnt + m) - cnt == k){
ans = min(ans, __builtin_popcount(mask));
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |