# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471725 | 2021-09-10T14:32:48 Z | rainboy | Izbori (COCI17_izbori) | C | 18 ms | 2340 KB |
#include <stdio.h> #define N 15 int max(int a, int b) { return a > b ? a : b; } int main() { static int kk[1 << N][N], cnt[1 << N]; int n, m, i_, i, b, ans; scanf("%d%d%d", &m, &n, &i_), i_--; while (m--) { static int pp[N]; for (i = 0; i < n; i++) scanf("%d", &pp[i]), pp[i]--; for (b = 1; b < 1 << n; b++) for (i = 0; i < n; i++) if ((b & 1 << pp[i]) != 0) { kk[b][pp[i]]++; break; } } for (b = 1; b < 1 << n; b++) cnt[b] = cnt[b & b - 1] + 1; ans = 0; for (b = 1; b < 1 << n; b++) if ((b & 1 << i_) != 0) { int win = 1; for (i = 0; i < n; i++) if (i != i_ && kk[b][i_] < kk[b][i] || kk[b][i_] == kk[b][i] && i_ > i) { win = 0; break; } if (win) ans = max(ans, cnt[b]); } ans = n - ans; i_ = -1; for (i = 0; i < n; i++) if (i_ == -1 || kk[(1 << n) - 1][i_] < kk[(1 << n) - 1][i]) i_ = i; printf("%d\n", i_ + 1); printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 408 KB | Output is correct |
2 | Correct | 2 ms | 2312 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 4 ms | 772 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 420 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 3 ms | 2256 KB | Output is correct |
9 | Correct | 3 ms | 464 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 2 ms | 468 KB | Output is correct |
12 | Correct | 8 ms | 1248 KB | Output is correct |
13 | Correct | 14 ms | 2340 KB | Output is correct |
14 | Correct | 8 ms | 1228 KB | Output is correct |
15 | Correct | 2 ms | 460 KB | Output is correct |
16 | Correct | 17 ms | 2340 KB | Output is correct |
17 | Correct | 8 ms | 1248 KB | Output is correct |
18 | Correct | 17 ms | 2312 KB | Output is correct |
19 | Correct | 18 ms | 2200 KB | Output is correct |
20 | Correct | 17 ms | 2340 KB | Output is correct |