# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087914 | vjudge1 | Izbori (COCI17_izbori) | C++17 | 1 ms | 456 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
}
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;
}
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |