#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const int maxm = 16;
int N, M, K;
int a;
int cnt[maxm];
queue <int> q[maxn];
int main()
{
cin >> N >> M >> K;
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++)
{cin >> a; q[i].push(a);}
for (int i = 0; i < N; i++)
cnt[q[i].front()]++;
int sol;
int ima = 0;
for (int i = 1; i <= M; i++)
if (cnt[i] > ima) {ima = cnt[i]; sol = i;}
cout << sol << endl;
int rj = 1e9;
int m = (1 << M);
for (int i = 0; i < m; i++)
{
int curr = __builtin_popcount(i);
queue <int> newq[N];
for (int j = 0; j < N; j++)
newq[j] = q[j];
for (int j = 0; j < N; j++)
while (((1 << (newq[j].front() - 1)) & i) == (1 << (newq[j].front() - 1)))
newq[j].pop();
memset(cnt, 0, sizeof cnt);
int ima = 0;
for (int j = 1; j <= M; j++)
if (cnt[j] > ima) {ima = cnt[j]; sol = j;}
if (sol == K) rj = min(rj, curr);
}
cout << rj << endl;
}
Compilation message
izbori.cpp: In function 'int main()':
izbori.cpp:26:10: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
cout << sol << endl;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
41 ms |
504 KB |
Partially correct |
2 |
Partially correct |
50 ms |
380 KB |
Partially correct |
3 |
Partially correct |
20 ms |
504 KB |
Partially correct |
4 |
Partially correct |
151 ms |
504 KB |
Partially correct |
5 |
Partially correct |
36 ms |
504 KB |
Partially correct |
6 |
Partially correct |
23 ms |
376 KB |
Partially correct |
7 |
Partially correct |
6 ms |
504 KB |
Partially correct |
8 |
Partially correct |
80 ms |
376 KB |
Partially correct |
9 |
Partially correct |
85 ms |
504 KB |
Partially correct |
10 |
Partially correct |
6 ms |
376 KB |
Partially correct |
11 |
Correct |
78 ms |
552 KB |
Output is correct |
12 |
Partially correct |
320 ms |
504 KB |
Partially correct |
13 |
Partially correct |
619 ms |
504 KB |
Partially correct |
14 |
Partially correct |
310 ms |
504 KB |
Partially correct |
15 |
Partially correct |
80 ms |
504 KB |
Partially correct |
16 |
Partially correct |
671 ms |
504 KB |
Partially correct |
17 |
Partially correct |
321 ms |
508 KB |
Partially correct |
18 |
Partially correct |
648 ms |
504 KB |
Partially correct |
19 |
Partially correct |
679 ms |
504 KB |
Partially correct |
20 |
Partially correct |
675 ms |
504 KB |
Partially correct |