#pragma GCC optimize("unroll-loops,O3")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//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;
}
#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 = (bs[i] ^ bs[j]).count();
tot += min(c, n - c);
}
if(tot <= k) {
return cout << "DA" << "\n", void();
}
}
if(k == n) {
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
bs[i][j] = !bs[i][j];
int tot = 0;
for(int j = 1; j <= n; j++) {
int c = (bs[i] ^ bs[j]).count();
tot += min(c, n - c);
}
if(tot <= k -1) {
return cout << "DA" << "\n", void();
}
bs[i][j] = !bs[i][j];
}
}
}
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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
492 KB |
Output is correct |
4 |
Correct |
13 ms |
348 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
348 KB |
Output is correct |
8 |
Correct |
19 ms |
576 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
19 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
348 KB |
Output is correct |
2 |
Correct |
11 ms |
488 KB |
Output is correct |
3 |
Correct |
7 ms |
344 KB |
Output is correct |
4 |
Correct |
7 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
488 KB |
Output is correct |
6 |
Correct |
6 ms |
348 KB |
Output is correct |
7 |
Correct |
11 ms |
464 KB |
Output is correct |
8 |
Correct |
12 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
21 ms |
584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
348 KB |
Output is correct |
2 |
Correct |
11 ms |
520 KB |
Output is correct |
3 |
Correct |
7 ms |
348 KB |
Output is correct |
4 |
Correct |
9 ms |
348 KB |
Output is correct |
5 |
Correct |
9 ms |
516 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
9 |
Correct |
13 ms |
344 KB |
Output is correct |
10 |
Correct |
21 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
532 KB |
Output is correct |
3 |
Correct |
23 ms |
348 KB |
Output is correct |
4 |
Correct |
7 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
476 KB |
Output is correct |
6 |
Correct |
4720 ms |
556 KB |
Output is correct |
7 |
Correct |
780 ms |
500 KB |
Output is correct |
8 |
Correct |
927 ms |
596 KB |
Output is correct |
9 |
Correct |
1002 ms |
508 KB |
Output is correct |
10 |
Correct |
929 ms |
520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
344 KB |
Output is correct |
2 |
Correct |
14 ms |
348 KB |
Output is correct |
3 |
Correct |
21 ms |
348 KB |
Output is correct |
4 |
Correct |
14 ms |
556 KB |
Output is correct |
5 |
Correct |
13 ms |
604 KB |
Output is correct |
6 |
Correct |
2231 ms |
536 KB |
Output is correct |
7 |
Correct |
896 ms |
508 KB |
Output is correct |
8 |
Correct |
3617 ms |
564 KB |
Output is correct |
9 |
Correct |
1429 ms |
520 KB |
Output is correct |
10 |
Correct |
4624 ms |
556 KB |
Output is correct |