#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, int cnt) {
if (cn == m) return;
int f[20] = {};
for (int i = 0; i < n; i++) {
int j = 0;
while (j < m && v[a[i][j]]) j++;
if (j < m) 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, cnt);
if (cn == 0) co num << '\n';
sol(v, cn + 1, cnt + 1);
v[cn + 1] = 1;
sol(v, cn + 1, cnt);
}
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(20, 0);
ans = m - 1;
sol(v, 0, 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, int)':
izbori.cpp:32:28: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | if (cn == 0) co num << '\n';
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Partially correct |
2 |
Partially correct |
6 ms |
460 KB |
Partially correct |
3 |
Partially correct |
1 ms |
348 KB |
Partially correct |
4 |
Partially correct |
4 ms |
348 KB |
Partially correct |
5 |
Partially correct |
1 ms |
348 KB |
Partially correct |
6 |
Partially correct |
1 ms |
348 KB |
Partially correct |
7 |
Partially correct |
0 ms |
348 KB |
Partially correct |
8 |
Partially correct |
6 ms |
460 KB |
Partially correct |
9 |
Partially correct |
3 ms |
600 KB |
Partially correct |
10 |
Partially correct |
1 ms |
348 KB |
Partially correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Partially correct |
8 ms |
460 KB |
Partially correct |
13 |
Partially correct |
14 ms |
348 KB |
Partially correct |
14 |
Partially correct |
10 ms |
348 KB |
Partially correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
16 ms |
344 KB |
Output is correct |
17 |
Partially correct |
9 ms |
348 KB |
Partially correct |
18 |
Partially correct |
15 ms |
344 KB |
Partially correct |
19 |
Partially correct |
17 ms |
348 KB |
Partially correct |
20 |
Partially correct |
18 ms |
348 KB |
Partially correct |