# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200392 | 2020-02-06T15:11:15 Z | quocnguyen1012 | Sajam (COCI18_sajam) | C++14 | 27 ms | 5240 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 = 0, 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 -= 2 * 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 504 KB | Output is correct |
2 | Correct | 9 ms | 2168 KB | Output is correct |
3 | Correct | 11 ms | 2680 KB | Output is correct |
4 | Correct | 22 ms | 4728 KB | Output is correct |
5 | Correct | 11 ms | 2680 KB | Output is correct |
6 | Correct | 7 ms | 1656 KB | Output is correct |
7 | Incorrect | 11 ms | 2680 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 632 KB | Output is correct |
3 | Correct | 5 ms | 760 KB | Output is correct |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 5 ms | 632 KB | Output is correct |
6 | Incorrect | 6 ms | 632 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 3808 KB | Output is correct |
2 | Correct | 19 ms | 4340 KB | Output is correct |
3 | Correct | 15 ms | 3476 KB | Output is correct |
4 | Correct | 14 ms | 3192 KB | Output is correct |
5 | Correct | 21 ms | 4728 KB | Output is correct |
6 | Incorrect | 12 ms | 2680 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 4472 KB | Output is correct |
2 | Correct | 20 ms | 4472 KB | Output is correct |
3 | Correct | 14 ms | 3320 KB | Output is correct |
4 | Correct | 16 ms | 3704 KB | Output is correct |
5 | Correct | 20 ms | 3832 KB | Output is correct |
6 | Incorrect | 24 ms | 5112 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 3448 KB | Output is correct |
2 | Correct | 14 ms | 3320 KB | Output is correct |
3 | Correct | 25 ms | 5112 KB | Output is correct |
4 | Correct | 11 ms | 2680 KB | Output is correct |
5 | Correct | 14 ms | 3320 KB | Output is correct |
6 | Incorrect | 24 ms | 5112 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 5240 KB | Output is correct |
2 | Correct | 24 ms | 5112 KB | Output is correct |
3 | Correct | 23 ms | 4856 KB | Output is correct |
4 | Correct | 17 ms | 3704 KB | Output is correct |
5 | Correct | 16 ms | 3832 KB | Output is correct |
6 | Incorrect | 18 ms | 3960 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |