#include<bits/stdc++.h>
using namespace std;
int n, m, k, x, rj=20;
int polje [110][17];
int brojac [15];
int main ( ){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k;
k--;
for (int i=0; i<n; i++){
for (int j=0; j<m; j++){
cin >> polje [i][j];
polje[i][j]--;
}
}
for (int mask=0; mask<(1<<m); mask++){
if (mask & (1<<k)) continue;
for (int i=0; i<m; i++) brojac[i]=0;
for (int i=0; i<n; i++){
int j=0;
while (mask & (1<<polje[i][j])) j++;
brojac [polje[i][j]]++;
}
x=0;
for (int i=1; i<m; i++){
if (brojac[i]>brojac[x]) x=i;
}
if (mask==0) cout << x+1 << endl;
if (x==k){
x=0;
for (int i=0; i<m; i++){
if (mask & (1<<i)){
x++;
}
}
rj = min(rj, x);
}
}
cout << rj;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
14 ms |
376 KB |
Output is correct |
14 |
Correct |
8 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
16 ms |
292 KB |
Output is correct |
17 |
Correct |
9 ms |
376 KB |
Output is correct |
18 |
Correct |
15 ms |
376 KB |
Output is correct |
19 |
Correct |
16 ms |
376 KB |
Output is correct |
20 |
Correct |
16 ms |
376 KB |
Output is correct |