# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
198595 | 2020-01-26T18:31:53 Z | ZwariowanyMarcin | Izbori (COCI17_izbori) | C++14 | 22 ms | 376 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define LL long long #define ld long double #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, j, n) for(int i = j; i <= n; ++i) #define boost cin.tie(0), ios_base::sync_with_stdio(0); using namespace std; const int nax = 110; int n, m, k; int a[nax][nax]; int points[nax]; int alive[nax]; int main() { scanf ("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) scanf ("%d", &a[i][j]); points[a[i][1]]++; } pair <int, int> winner = {-1, 0}; for (int i = 1; i <= n; ++i) winner = max(winner, {points[i], -i}); printf ("%d\n", -1 * winner.se); int ans = m - 1; for (int mask = 0; mask < (1 << m) - 1; ++mask) { if ((mask >> k) & 1) continue; for (int i = 0; i < m; ++i) { alive[i + 1] = !((mask >> i) & 1); points[i + 1] = 0; } for (int i = 1; i <= n; ++i) { int j = 1; while (!alive[a[i][j]]) j++; points[a[i][j]]++; } pair <int, int> winner = {-1, 0}; for (int k = 1; k <= m; ++k) winner = max(winner, {points[k], -k}); if (winner.se == -k) ans = min(ans, __builtin_popcount(mask)); } printf ("%d", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 6 ms | 376 KB | Partially correct |
2 | Partially correct | 6 ms | 256 KB | Partially correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 8 ms | 376 KB | Output is correct |
5 | Partially correct | 6 ms | 376 KB | Partially correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Partially correct | 7 ms | 256 KB | Partially correct |
9 | Correct | 9 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |
11 | Correct | 7 ms | 376 KB | Output is correct |
12 | Correct | 13 ms | 376 KB | Output is correct |
13 | Correct | 19 ms | 376 KB | Output is correct |
14 | Correct | 13 ms | 376 KB | Output is correct |
15 | Correct | 7 ms | 376 KB | Output is correct |
16 | Correct | 22 ms | 376 KB | Output is correct |
17 | Correct | 12 ms | 376 KB | Output is correct |
18 | Partially correct | 21 ms | 376 KB | Partially correct |
19 | Correct | 22 ms | 376 KB | Output is correct |
20 | Correct | 21 ms | 376 KB | Output is correct |