#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 ((newq[j].front() & curr) == newq[j].front())
newq[j].pop();
memset(cnt, 0, sizeof cnt);
for (int j = 0; j < N; j++)
if (!newq[j].empty())
cnt[newq[j].front()]++;
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 |
632 KB |
Partially correct |
2 |
Runtime error |
52 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
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 |
24 ms |
376 KB |
Partially correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Runtime error |
80 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Partially correct |
87 ms |
504 KB |
Partially correct |
10 |
Partially correct |
6 ms |
376 KB |
Partially correct |
11 |
Correct |
80 ms |
504 KB |
Output is correct |
12 |
Partially correct |
314 ms |
504 KB |
Partially correct |
13 |
Runtime error |
626 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Partially correct |
318 ms |
504 KB |
Partially correct |
15 |
Partially correct |
79 ms |
504 KB |
Partially correct |
16 |
Runtime error |
677 ms |
816 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Partially correct |
320 ms |
504 KB |
Partially correct |
18 |
Runtime error |
653 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
676 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
675 ms |
892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |