//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
bitset <1005> bs[1005];
char getc() {
char ch;
cin >> ch;
return ch;
}
int dist(bitset <1005> &a, bitset <1005> &b) {
return (a ^ b).count();
}
#define ONLINE_JUDGE
void solve() {
int n, k;
cin >> n >> k;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
bs[i][j] = (getc() == 'o');
}
}
for(int i = 1; i <= n; i++) {
int tot = 0;
for(int j = 1; j <= n; j++) {
int c = dist(bs[i], bs[j]);
tot += min(c, n - c);
}
if(tot <= k) {
return cout << "DA" << "\n", void();
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
bs[i][j] = bs[i][j] ^ 1;
int tot = 0;
for(int j = 1; j <= n; j++) {
int c = dist(bs[i], bs[j]);
tot += min(c, n - c);
}
if(tot <= k -1) {
return cout << "DA" << "\n", void();
}
bs[i][j] = bs[i][j] ^ 1;
}
}
cout << "NE";
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
3 ms |
604 KB |
Output is correct |
3 |
Correct |
4 ms |
584 KB |
Output is correct |
4 |
Correct |
13 ms |
1364 KB |
Output is correct |
5 |
Correct |
5 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
832 KB |
Output is correct |
7 |
Execution timed out |
5044 ms |
604 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
11 ms |
344 KB |
Output is correct |
7 |
Correct |
29 ms |
344 KB |
Output is correct |
8 |
Correct |
9 ms |
348 KB |
Output is correct |
9 |
Correct |
18 ms |
476 KB |
Output is correct |
10 |
Correct |
14 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1116 KB |
Output is correct |
2 |
Correct |
12 ms |
1104 KB |
Output is correct |
3 |
Correct |
7 ms |
860 KB |
Output is correct |
4 |
Correct |
7 ms |
856 KB |
Output is correct |
5 |
Correct |
14 ms |
1372 KB |
Output is correct |
6 |
Execution timed out |
5055 ms |
604 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1116 KB |
Output is correct |
2 |
Correct |
12 ms |
1116 KB |
Output is correct |
3 |
Correct |
7 ms |
856 KB |
Output is correct |
4 |
Correct |
9 ms |
836 KB |
Output is correct |
5 |
Correct |
9 ms |
1116 KB |
Output is correct |
6 |
Execution timed out |
5070 ms |
1372 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
856 KB |
Output is correct |
2 |
Correct |
7 ms |
856 KB |
Output is correct |
3 |
Correct |
79 ms |
1372 KB |
Output is correct |
4 |
Correct |
26 ms |
604 KB |
Output is correct |
5 |
Correct |
39 ms |
1196 KB |
Output is correct |
6 |
Execution timed out |
5055 ms |
1372 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
1368 KB |
Output is correct |
2 |
Correct |
15 ms |
1372 KB |
Output is correct |
3 |
Correct |
74 ms |
1368 KB |
Output is correct |
4 |
Correct |
54 ms |
856 KB |
Output is correct |
5 |
Correct |
32 ms |
856 KB |
Output is correct |
6 |
Execution timed out |
5017 ms |
856 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |