#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long
const int maxn=2e3+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 coun=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];
}
coun+=min(u,n-u);
}
if(coun<=k){
cout<<YES<<endl;
return 0;
}
for(int i=0;i<n;i++){
int cnt=0;
for(int j=0;j<n;j++){
int z=(bit[i]^bit[j]).count();
cnt+=min(z,n-z);
}
if(cnt<=k){
cout<<YES<<endl;
return 0;
}
}
bitset<maxn> b = bit[0];
for(int i=0;i<n;i++){
int cnt=0;
for(int j=0;j<n;j++){
int cn=(bit[j]^b).count();
cn=min(cn,n-cn);
cnt+=cn;
}
if(cnt<=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 |
21 ms |
632 KB |
Output is correct |
3 |
Correct |
30 ms |
760 KB |
Output is correct |
4 |
Correct |
89 ms |
888 KB |
Output is correct |
5 |
Correct |
29 ms |
760 KB |
Output is correct |
6 |
Correct |
15 ms |
504 KB |
Output is correct |
7 |
Correct |
93 ms |
632 KB |
Output is correct |
8 |
Correct |
314 ms |
888 KB |
Output is correct |
9 |
Correct |
29 ms |
376 KB |
Output is correct |
10 |
Correct |
312 ms |
956 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 |
7 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
768 KB |
Output is correct |
2 |
Correct |
67 ms |
888 KB |
Output is correct |
3 |
Correct |
46 ms |
940 KB |
Output is correct |
4 |
Correct |
42 ms |
864 KB |
Output is correct |
5 |
Correct |
77 ms |
864 KB |
Output is correct |
6 |
Correct |
111 ms |
760 KB |
Output is correct |
7 |
Correct |
199 ms |
864 KB |
Output is correct |
8 |
Correct |
212 ms |
1016 KB |
Output is correct |
9 |
Correct |
59 ms |
504 KB |
Output is correct |
10 |
Correct |
344 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
864 KB |
Output is correct |
2 |
Correct |
73 ms |
888 KB |
Output is correct |
3 |
Correct |
47 ms |
888 KB |
Output is correct |
4 |
Correct |
53 ms |
760 KB |
Output is correct |
5 |
Correct |
59 ms |
888 KB |
Output is correct |
6 |
Correct |
351 ms |
992 KB |
Output is correct |
7 |
Correct |
84 ms |
708 KB |
Output is correct |
8 |
Correct |
185 ms |
888 KB |
Output is correct |
9 |
Correct |
201 ms |
888 KB |
Output is correct |
10 |
Correct |
342 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
888 KB |
Output is correct |
2 |
Correct |
43 ms |
888 KB |
Output is correct |
3 |
Incorrect |
362 ms |
936 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
888 KB |
Output is correct |
2 |
Correct |
106 ms |
884 KB |
Output is correct |
3 |
Incorrect |
307 ms |
888 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |