#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");
for(int i = 0 ; i < n ; i++){
int cur = 0;
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) finish("DA");
}
cout << "NE\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
17 ms |
376 KB |
Output is correct |
3 |
Correct |
23 ms |
376 KB |
Output is correct |
4 |
Correct |
64 ms |
504 KB |
Output is correct |
5 |
Correct |
24 ms |
376 KB |
Output is correct |
6 |
Correct |
12 ms |
376 KB |
Output is correct |
7 |
Correct |
39 ms |
504 KB |
Output is correct |
8 |
Correct |
126 ms |
504 KB |
Output is correct |
9 |
Correct |
12 ms |
376 KB |
Output is correct |
10 |
Correct |
123 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
504 KB |
Output is correct |
2 |
Correct |
53 ms |
504 KB |
Output is correct |
3 |
Correct |
38 ms |
376 KB |
Output is correct |
4 |
Correct |
33 ms |
376 KB |
Output is correct |
5 |
Correct |
61 ms |
504 KB |
Output is correct |
6 |
Correct |
43 ms |
376 KB |
Output is correct |
7 |
Correct |
90 ms |
504 KB |
Output is correct |
8 |
Correct |
83 ms |
376 KB |
Output is correct |
9 |
Correct |
26 ms |
376 KB |
Output is correct |
10 |
Correct |
140 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
504 KB |
Output is correct |
2 |
Correct |
60 ms |
504 KB |
Output is correct |
3 |
Correct |
34 ms |
504 KB |
Output is correct |
4 |
Correct |
43 ms |
376 KB |
Output is correct |
5 |
Correct |
269 ms |
504 KB |
Output is correct |
6 |
Correct |
137 ms |
632 KB |
Output is correct |
7 |
Correct |
35 ms |
376 KB |
Output is correct |
8 |
Correct |
74 ms |
376 KB |
Output is correct |
9 |
Correct |
84 ms |
380 KB |
Output is correct |
10 |
Correct |
145 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
504 KB |
Output is correct |
2 |
Correct |
34 ms |
504 KB |
Output is correct |
3 |
Correct |
105 ms |
504 KB |
Output is correct |
4 |
Correct |
39 ms |
376 KB |
Output is correct |
5 |
Correct |
43 ms |
376 KB |
Output is correct |
6 |
Correct |
161 ms |
632 KB |
Output is correct |
7 |
Correct |
42 ms |
376 KB |
Output is correct |
8 |
Correct |
48 ms |
380 KB |
Output is correct |
9 |
Correct |
50 ms |
376 KB |
Output is correct |
10 |
Correct |
48 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
504 KB |
Output is correct |
2 |
Correct |
83 ms |
636 KB |
Output is correct |
3 |
Correct |
96 ms |
504 KB |
Output is correct |
4 |
Correct |
77 ms |
376 KB |
Output is correct |
5 |
Correct |
43 ms |
376 KB |
Output is correct |
6 |
Correct |
85 ms |
376 KB |
Output is correct |
7 |
Correct |
44 ms |
452 KB |
Output is correct |
8 |
Correct |
106 ms |
504 KB |
Output is correct |
9 |
Correct |
61 ms |
376 KB |
Output is correct |
10 |
Correct |
130 ms |
508 KB |
Output is correct |