#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()) & i) == (1 << newq[j].front()))
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 |
40 ms |
508 KB |
Partially correct |
2 |
Partially correct |
50 ms |
376 KB |
Partially correct |
3 |
Partially correct |
20 ms |
504 KB |
Partially correct |
4 |
Partially correct |
150 ms |
504 KB |
Partially correct |
5 |
Partially correct |
37 ms |
504 KB |
Partially correct |
6 |
Partially correct |
23 ms |
504 KB |
Partially correct |
7 |
Partially correct |
6 ms |
504 KB |
Partially correct |
8 |
Partially correct |
78 ms |
376 KB |
Partially correct |
9 |
Partially correct |
83 ms |
468 KB |
Partially correct |
10 |
Partially correct |
6 ms |
376 KB |
Partially correct |
11 |
Correct |
77 ms |
504 KB |
Output is correct |
12 |
Partially correct |
312 ms |
504 KB |
Partially correct |
13 |
Partially correct |
609 ms |
504 KB |
Partially correct |
14 |
Partially correct |
305 ms |
504 KB |
Partially correct |
15 |
Partially correct |
79 ms |
504 KB |
Partially correct |
16 |
Partially correct |
656 ms |
504 KB |
Partially correct |
17 |
Partially correct |
315 ms |
504 KB |
Partially correct |
18 |
Partially correct |
639 ms |
504 KB |
Partially correct |
19 |
Partially correct |
661 ms |
504 KB |
Partially correct |
20 |
Partially correct |
664 ms |
504 KB |
Partially correct |