# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
200395 | 2020-02-06T15:16:41 Z | quocnguyen1012 | Sajam (COCI18_sajam) | C++14 | 30 ms | 5244 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; const int maxn = 1005; int a[maxn][maxn], cnt[2][maxn], N; bool mark[2][maxn]; int sum = 0, K; signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> K; for (int i = 1; i <= N; ++i){ for (int j = 1; j <= N; ++j){ char x; cin >> x; a[i][j] = (x == 'o'); cnt[0][i] += a[i][j]; cnt[1][j] += a[i][j]; sum += a[i][j]; } } if (sum <= K){ cout << "DA"; return 0; } for (int z = 1; z <= N; ++z){ int type, mx = -1, ind; for (int t = 0; t < 2; ++t){ for (int i = 1; i <= N; ++i){ if (mx < cnt[t][i] && mark[t][i] == false){ mx = cnt[t][i]; ind = i; type = t; } } } sum -= cnt[type][ind]; cnt[type][ind] = N - cnt[type][ind]; sum += cnt[type][ind]; mark[type][ind] = true; if (sum <= K){ cout << "DA"; return 0; } if (type == 0){ for (int i = 1; i <= N; ++i){ cnt[1][i] -= a[ind][i]; a[ind][i] ^= 1; cnt[1][i] += a[ind][i]; } } else{ for (int i = 1; i <= N; ++i){ cnt[0][i] -= a[i][ind]; a[i][ind] ^= 1; cnt[0][i] += a[i][ind]; } } } cout << "NE"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 504 KB | Output is correct |
2 | Correct | 9 ms | 2040 KB | Output is correct |
3 | Correct | 11 ms | 2424 KB | Output is correct |
4 | Correct | 22 ms | 3960 KB | Output is correct |
5 | Correct | 8 ms | 2424 KB | Output is correct |
6 | Correct | 7 ms | 1660 KB | Output is correct |
7 | Correct | 11 ms | 2296 KB | Output is correct |
8 | Correct | 24 ms | 4856 KB | Output is correct |
9 | Correct | 8 ms | 1400 KB | Output is correct |
10 | Correct | 25 ms | 4856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 632 KB | Output is correct |
3 | Correct | 5 ms | 632 KB | Output is correct |
4 | Correct | 5 ms | 636 KB | Output is correct |
5 | Correct | 5 ms | 636 KB | Output is correct |
6 | Correct | 5 ms | 632 KB | Output is correct |
7 | Correct | 5 ms | 636 KB | Output is correct |
8 | Correct | 5 ms | 632 KB | Output is correct |
9 | Correct | 6 ms | 632 KB | Output is correct |
10 | Correct | 6 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 3316 KB | Output is correct |
2 | Correct | 23 ms | 3580 KB | Output is correct |
3 | Correct | 15 ms | 3064 KB | Output is correct |
4 | Correct | 14 ms | 2808 KB | Output is correct |
5 | Correct | 21 ms | 3832 KB | Output is correct |
6 | Correct | 12 ms | 2424 KB | Output is correct |
7 | Correct | 17 ms | 3832 KB | Output is correct |
8 | Correct | 19 ms | 3960 KB | Output is correct |
9 | Correct | 10 ms | 2168 KB | Output is correct |
10 | Correct | 30 ms | 5244 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 3704 KB | Output is correct |
2 | Correct | 25 ms | 3704 KB | Output is correct |
3 | Correct | 14 ms | 2936 KB | Output is correct |
4 | Correct | 16 ms | 3192 KB | Output is correct |
5 | Correct | 17 ms | 3320 KB | Output is correct |
6 | Correct | 25 ms | 4088 KB | Output is correct |
7 | Correct | 10 ms | 2424 KB | Output is correct |
8 | Correct | 17 ms | 3704 KB | Output is correct |
9 | Correct | 19 ms | 3832 KB | Output is correct |
10 | Correct | 28 ms | 5240 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 2936 KB | Output is correct |
2 | Correct | 14 ms | 2936 KB | Output is correct |
3 | Correct | 29 ms | 4180 KB | Output is correct |
4 | Correct | 11 ms | 2424 KB | Output is correct |
5 | Correct | 14 ms | 2936 KB | Output is correct |
6 | Correct | 24 ms | 4088 KB | Output is correct |
7 | Correct | 11 ms | 2680 KB | Output is correct |
8 | Correct | 12 ms | 2808 KB | Output is correct |
9 | Correct | 14 ms | 2940 KB | Output is correct |
10 | Correct | 12 ms | 2808 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 4216 KB | Output is correct |
2 | Correct | 25 ms | 4216 KB | Output is correct |
3 | Correct | 26 ms | 3964 KB | Output is correct |
4 | Correct | 17 ms | 3192 KB | Output is correct |
5 | Correct | 17 ms | 3192 KB | Output is correct |
6 | Correct | 18 ms | 3320 KB | Output is correct |
7 | Correct | 12 ms | 2808 KB | Output is correct |
8 | Correct | 23 ms | 4468 KB | Output is correct |
9 | Correct | 15 ms | 3320 KB | Output is correct |
10 | Correct | 26 ms | 4984 KB | Output is correct |