#include "bits/stdc++.h"
const signed MOD = 1e9 + 7;
const signed mod = 998244353;
using namespace std;
#define all(x) x.begin(), x.end()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define co cout <<
#define S second
#define F first
int n, m, k, ans, a[105][20];
void sol(vector<bool> v, int cn) {
if (cn == m) return;
v.pb(0);
sol(v, cn + 1);
v.pop_back();
v.pb(1);
sol(v, cn + 1);
int f[20] = {};
for (int i = 0; i < n; i++) {
int j = 0;
while (v[a[i][j]]) j++;
f[a[i][j]]++;
}
int mx = 0, num;
for (int i = 1; i <= m; i++) {
if (f[i] > mx) {
mx = f[i];
num = i;
}
}
if (num == k) ans = min(ans, cn);
if (cn == 0) co num << '\n';
}
void solve() {
cin >> n >> m >> k;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
vector<bool> v;
ans = m - 1;
sol(v, 0);
co ans;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
signed t = 1;
// cin >> t;
while (t--) solve();
}
Compilation message
izbori.cpp: In function 'void sol(std::vector<bool>, int)':
izbori.cpp:37:28: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
37 | if (cn == 0) co num << '\n';
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Partially correct |
4 ms |
348 KB |
Partially correct |
3 |
Partially correct |
1 ms |
348 KB |
Partially correct |
4 |
Runtime error |
5 ms |
464 KB |
Execution killed with signal 11 |
5 |
Partially correct |
2 ms |
348 KB |
Partially correct |
6 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Partially correct |
5 ms |
348 KB |
Partially correct |
9 |
Partially correct |
3 ms |
348 KB |
Partially correct |
10 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
11 |
Correct |
3 ms |
824 KB |
Output is correct |
12 |
Partially correct |
10 ms |
596 KB |
Partially correct |
13 |
Partially correct |
14 ms |
348 KB |
Partially correct |
14 |
Runtime error |
12 ms |
604 KB |
Execution killed with signal 11 |
15 |
Partially correct |
3 ms |
344 KB |
Partially correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Partially correct |
8 ms |
348 KB |
Partially correct |
18 |
Partially correct |
17 ms |
344 KB |
Partially correct |
19 |
Partially correct |
20 ms |
344 KB |
Partially correct |
20 |
Correct |
21 ms |
472 KB |
Output is correct |