# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087915 |
2024-09-13T13:25:37 Z |
vjudge1 |
Izbori (COCI17_izbori) |
C++17 |
|
1 ms |
460 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
void solve() {
int n, m, k;
cin >> n >> m >> k;
bool t[20] = {};
int a[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
int g[20] = {};
for (int i = 0; i < n; i++) {
int j = 0;
while (t[a[i][j]]) j++;
g[a[i][j]]++;
}
int mx = 0, num;
for (int i = 1; i <= m; i++) {
if (g[i] > mx) {
mx = g[i];
num = i;
}
else if (g[i] == mx) {
num = min(i, num);
}
}
int cn = 0;
co num;
while (1) {
int f[20] = {};
for (int i = 0; i < n; i++) {
int j = 0;
while (t[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;
}
else if (f[i] == mx) {
num = min(i, num);
}
}
if (num == k) {
co '\n' << cn;
return;
}
cn++;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j] == num) {
t[num] = 1;
continue;
}
}
}
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
signed t = 1;
// cin >> t;
while (t--) solve();
}
Compilation message
izbori.cpp: In function 'void solve()':
izbori.cpp:63:9: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
63 | if (num == k) {
| ^~
izbori.cpp:43:8: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
43 | co num;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
4 |
Partially correct |
1 ms |
348 KB |
Partially correct |
5 |
Partially correct |
0 ms |
348 KB |
Partially correct |
6 |
Partially correct |
0 ms |
452 KB |
Partially correct |
7 |
Partially correct |
0 ms |
348 KB |
Partially correct |
8 |
Partially correct |
0 ms |
348 KB |
Partially correct |
9 |
Partially correct |
0 ms |
348 KB |
Partially correct |
10 |
Partially correct |
0 ms |
348 KB |
Partially correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Partially correct |
1 ms |
344 KB |
Partially correct |
14 |
Partially correct |
0 ms |
348 KB |
Partially correct |
15 |
Partially correct |
0 ms |
348 KB |
Partially correct |
16 |
Partially correct |
1 ms |
348 KB |
Partially correct |
17 |
Partially correct |
0 ms |
348 KB |
Partially correct |
18 |
Partially correct |
0 ms |
348 KB |
Partially correct |
19 |
Partially correct |
0 ms |
460 KB |
Partially correct |
20 |
Partially correct |
1 ms |
348 KB |
Partially correct |