# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200394 | 2020-02-06T15:15:27 Z | quocnguyen1012 | Sajam (COCI18_sajam) | C++14 | 35 ms | 4344 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 -= cnt[type][ind]; cnt[type][ind] = N - cnt[type][ind]; sum += cnt[type][ind]; mark[type][ind] = true; cerr << sum << '\n'; 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 | Incorrect | 5 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 3320 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 3832 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 2936 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 4344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |