#include <bits/stdc++.h>
using namespace std;
signed main()
{
int n, m, k;
cin >> n >> m >> k;
vector <vector <int> > A(n, vector <int> (m));
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
cin >> A[i][j];
A[i][j]--;
}
}
vector <int> cnt(m);
for(int i = 0; i < n; i++)
{
cnt[A[i][0]]++;
}
int maxid = 0;
for(int i = 1; i < m; i++)
{
if(cnt[i] > cnt[maxid])
{
maxid = i;
}
}
int ans = 1e9;
cout << maxid + 1 << "\n";
for(int mask = 0; mask < (1 << m); mask++)
{
for(int i = 0; i < m; i++)
{
cnt[i] = 0;
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(((1 << A[i][j]) & mask) == 0)
{
cnt[A[i][j]]++;
break;
}
}
}
int maxid = 0;
for(int i = 0; i < m; i++)
{
if(cnt[i] > cnt[maxid])
{
maxid = i;
}
}
if(maxid + 1 == k)
{
ans = min(ans, __builtin_popcount(mask));
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
12 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
9 ms |
256 KB |
Output is correct |
9 |
Correct |
9 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
9 ms |
384 KB |
Output is correct |
12 |
Correct |
21 ms |
384 KB |
Output is correct |
13 |
Correct |
36 ms |
256 KB |
Output is correct |
14 |
Correct |
20 ms |
384 KB |
Output is correct |
15 |
Correct |
9 ms |
256 KB |
Output is correct |
16 |
Correct |
42 ms |
384 KB |
Output is correct |
17 |
Correct |
22 ms |
256 KB |
Output is correct |
18 |
Correct |
39 ms |
384 KB |
Output is correct |
19 |
Correct |
41 ms |
384 KB |
Output is correct |
20 |
Correct |
41 ms |
376 KB |
Output is correct |