#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int maxm = 20;
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 |
1144 KB |
Partially correct |
2 |
Runtime error |
53 ms |
1912 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Partially correct |
21 ms |
1144 KB |
Partially correct |
4 |
Partially correct |
144 ms |
1016 KB |
Partially correct |
5 |
Partially correct |
37 ms |
1016 KB |
Partially correct |
6 |
Partially correct |
24 ms |
1016 KB |
Partially correct |
7 |
Correct |
7 ms |
1020 KB |
Output is correct |
8 |
Runtime error |
81 ms |
1912 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Partially correct |
82 ms |
1144 KB |
Partially correct |
10 |
Partially correct |
7 ms |
1016 KB |
Partially correct |
11 |
Correct |
73 ms |
1144 KB |
Output is correct |
12 |
Partially correct |
307 ms |
1144 KB |
Partially correct |
13 |
Runtime error |
598 ms |
2024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Partially correct |
298 ms |
1016 KB |
Partially correct |
15 |
Partially correct |
77 ms |
1016 KB |
Partially correct |
16 |
Partially correct |
599 ms |
1144 KB |
Partially correct |
17 |
Partially correct |
309 ms |
1016 KB |
Partially correct |
18 |
Runtime error |
627 ms |
2040 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Partially correct |
585 ms |
1144 KB |
Partially correct |
20 |
Partially correct |
588 ms |
1144 KB |
Partially correct |