#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
const int N = 1001;
int n, k, g[N][N];
bitset <N> b[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int i = 0 ; i < n ; i++){
string s;
cin >> s;
for(int j = 0 ; j < n ; j++){
if(s[j] == 'x') b[i].set(j);
}
}
int ans = n * n;
for(int i = 0 ; i < n ; i++){
int cur = 0;
for(int j = 0 ; j < n ; j++){
int c = (b[i] ^ b[j]).count();
cur += min(c, n - c);
}
ans = min(ans, cur);
}
if(ans <= k) finish("DA");
int cur = 0;
for(int i = 0 ; i < n ; i++){
b[0].flip(i);
for(int j = 0 ; j < n ; j++){
int c = (b[0] ^ b[j]).count();
cur += min(c, n - c);
}
b[0].flip(i);
}
if(cur < k) cout << "DA\n";
else cout << "NE\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
18 ms |
380 KB |
Output is correct |
3 |
Correct |
24 ms |
376 KB |
Output is correct |
4 |
Correct |
69 ms |
504 KB |
Output is correct |
5 |
Correct |
25 ms |
504 KB |
Output is correct |
6 |
Correct |
13 ms |
376 KB |
Output is correct |
7 |
Correct |
45 ms |
376 KB |
Output is correct |
8 |
Correct |
137 ms |
504 KB |
Output is correct |
9 |
Correct |
12 ms |
376 KB |
Output is correct |
10 |
Correct |
147 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
376 KB |
Output is correct |
2 |
Correct |
56 ms |
496 KB |
Output is correct |
3 |
Correct |
42 ms |
376 KB |
Output is correct |
4 |
Correct |
38 ms |
376 KB |
Output is correct |
5 |
Correct |
64 ms |
504 KB |
Output is correct |
6 |
Correct |
48 ms |
376 KB |
Output is correct |
7 |
Correct |
95 ms |
480 KB |
Output is correct |
8 |
Correct |
93 ms |
376 KB |
Output is correct |
9 |
Correct |
29 ms |
376 KB |
Output is correct |
10 |
Correct |
158 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
376 KB |
Output is correct |
2 |
Correct |
60 ms |
376 KB |
Output is correct |
3 |
Correct |
34 ms |
376 KB |
Output is correct |
4 |
Correct |
43 ms |
376 KB |
Output is correct |
5 |
Correct |
54 ms |
376 KB |
Output is correct |
6 |
Correct |
151 ms |
516 KB |
Output is correct |
7 |
Correct |
38 ms |
376 KB |
Output is correct |
8 |
Correct |
91 ms |
376 KB |
Output is correct |
9 |
Correct |
98 ms |
376 KB |
Output is correct |
10 |
Correct |
172 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
408 KB |
Output is correct |
2 |
Correct |
36 ms |
376 KB |
Output is correct |
3 |
Incorrect |
149 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
504 KB |
Output is correct |
2 |
Correct |
79 ms |
632 KB |
Output is correct |
3 |
Incorrect |
138 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |