#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long
const int maxn=1e3+5;
/*Almost copy pasted part :)*/
bitset <maxn> bit[maxn];
#define YES "DA"
#define NO "NE"
int32_t main(){
int n,k;
cin>>n>>k;
int cnt=0;
for(int i=0;i<n;i++){
int u=0;
for(int j=0;j<n;j++){
char a;
cin>>a;
bit[i][j]=(a=='x');
u+=bit[i][j];
}
cnt+=min(u,n-u);
}
if(cnt<=k){
cout<<YES<<endl;
return 0;
}
bitset<maxn>b=bit[0];
for(int i=0;i<n;i++){
int tmp=0;
for(int j=0;j<n;j++){
int cn=(bit[j]^b).count();
cn=min(cn,n-cn);
tmp+=cn;
}
if(tmp<=k){
cout<<YES<<endl;
return 0;
}
b[i]=(1-b[i]);
}
cout<<NO<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
20 ms |
504 KB |
Output is correct |
3 |
Correct |
28 ms |
632 KB |
Output is correct |
4 |
Correct |
77 ms |
1272 KB |
Output is correct |
5 |
Correct |
29 ms |
632 KB |
Output is correct |
6 |
Correct |
14 ms |
508 KB |
Output is correct |
7 |
Correct |
44 ms |
636 KB |
Output is correct |
8 |
Correct |
141 ms |
1400 KB |
Output is correct |
9 |
Correct |
13 ms |
376 KB |
Output is correct |
10 |
Correct |
145 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
6 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 |
54 ms |
992 KB |
Output is correct |
2 |
Correct |
66 ms |
1144 KB |
Output is correct |
3 |
Correct |
46 ms |
760 KB |
Output is correct |
4 |
Correct |
41 ms |
760 KB |
Output is correct |
5 |
Correct |
77 ms |
1272 KB |
Output is correct |
6 |
Correct |
51 ms |
632 KB |
Output is correct |
7 |
Correct |
90 ms |
888 KB |
Output is correct |
8 |
Correct |
102 ms |
1016 KB |
Output is correct |
9 |
Correct |
30 ms |
504 KB |
Output is correct |
10 |
Correct |
163 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
1312 KB |
Output is correct |
2 |
Correct |
70 ms |
1016 KB |
Output is correct |
3 |
Correct |
42 ms |
760 KB |
Output is correct |
4 |
Correct |
52 ms |
888 KB |
Output is correct |
5 |
Correct |
55 ms |
1016 KB |
Output is correct |
6 |
Correct |
149 ms |
1400 KB |
Output is correct |
7 |
Correct |
40 ms |
632 KB |
Output is correct |
8 |
Correct |
92 ms |
1144 KB |
Output is correct |
9 |
Correct |
93 ms |
1016 KB |
Output is correct |
10 |
Correct |
157 ms |
1560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
760 KB |
Output is correct |
2 |
Correct |
46 ms |
760 KB |
Output is correct |
3 |
Incorrect |
154 ms |
1456 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
1400 KB |
Output is correct |
2 |
Correct |
90 ms |
1400 KB |
Output is correct |
3 |
Incorrect |
141 ms |
1272 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |