# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1089023 |
2024-09-15T18:55:37 Z |
vjudge1 |
Izbori (COCI17_izbori) |
C++17 |
|
47 ms |
464 KB |
#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 + 1) 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, cn);
if (cn == 0) co num << '\n';
v[cn + 1] = 1;
sol(v, cn + 1);
v[cn + 1] = 0;
sol(v, cn + 1);
}
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);
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:32:28: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | if (cn == 0) co num << '\n';
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
348 KB |
Partially correct |
2 |
Partially correct |
11 ms |
348 KB |
Partially correct |
3 |
Partially correct |
1 ms |
348 KB |
Partially correct |
4 |
Partially correct |
8 ms |
348 KB |
Partially correct |
5 |
Partially correct |
2 ms |
348 KB |
Partially correct |
6 |
Partially correct |
2 ms |
348 KB |
Partially correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Partially correct |
12 ms |
448 KB |
Partially correct |
9 |
Partially correct |
6 ms |
344 KB |
Partially correct |
10 |
Partially correct |
1 ms |
348 KB |
Partially correct |
11 |
Correct |
5 ms |
348 KB |
Output is correct |
12 |
Partially correct |
18 ms |
464 KB |
Partially correct |
13 |
Partially correct |
38 ms |
348 KB |
Partially correct |
14 |
Partially correct |
18 ms |
348 KB |
Partially correct |
15 |
Partially correct |
6 ms |
348 KB |
Partially correct |
16 |
Partially correct |
47 ms |
436 KB |
Partially correct |
17 |
Partially correct |
19 ms |
344 KB |
Partially correct |
18 |
Partially correct |
37 ms |
348 KB |
Partially correct |
19 |
Partially correct |
40 ms |
440 KB |
Partially correct |
20 |
Partially correct |
40 ms |
348 KB |
Partially correct |