#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;int K;
int gr[1010][1010];
int ogr[1010][1010];
int rcal(int r){
int cnt=0;
for(int i=1;i<=n;i++){
cnt+=gr[r][i];
}
return min(cnt,n-cnt);
}
void solve(int rw){
for(int i=1;i<=n;i++){
if(gr[rw][i]==0){
for(int j=1;j<=n;j++){
gr[j][i]^=1;
}
}
}
int cal=0;
for(int i=1;i<=n;i++){
cal+=rcal(i);
}
if(cal<=K){
cout<<"DA\n";exit(0);
}
}
void rst(){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
gr[i][j]=ogr[i][j];
}
}
}
signed main(){
cin>>n>>K;
for(int i=1;i<=n;i++){
string s;
cin>>s;
s="*"+s;
for(int j=1;j<=n;j++){
if(s[j]=='o'){
gr[i][j]=0;
}else{
gr[i][j]=1;
}
ogr[i][j]=gr[i][j];
}
}
for(int i=1;i<=n;i++){
rst();
solve(i);
rst();
for(int j=1;j<=n;j++){
gr[i][j]^=1;
}
solve(i);
}
cout<<"NE\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
564 KB |
Output is correct |
2 |
Correct |
7 ms |
6612 KB |
Output is correct |
3 |
Correct |
9 ms |
8580 KB |
Output is correct |
4 |
Correct |
19 ms |
15052 KB |
Output is correct |
5 |
Correct |
7 ms |
8788 KB |
Output is correct |
6 |
Correct |
4 ms |
4564 KB |
Output is correct |
7 |
Correct |
300 ms |
8364 KB |
Output is correct |
8 |
Correct |
2235 ms |
15500 KB |
Output is correct |
9 |
Correct |
36 ms |
2936 KB |
Output is correct |
10 |
Correct |
2494 ms |
15620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
2 |
Correct |
1 ms |
852 KB |
Output is correct |
3 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
12580 KB |
Output is correct |
2 |
Correct |
17 ms |
14120 KB |
Output is correct |
3 |
Correct |
12 ms |
11460 KB |
Output is correct |
4 |
Correct |
10 ms |
10752 KB |
Output is correct |
5 |
Correct |
19 ms |
15284 KB |
Output is correct |
6 |
Correct |
370 ms |
9080 KB |
Output is correct |
7 |
Correct |
1033 ms |
12564 KB |
Output is correct |
8 |
Correct |
1177 ms |
13120 KB |
Output is correct |
9 |
Correct |
148 ms |
6176 KB |
Output is correct |
10 |
Correct |
2872 ms |
16888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
14520 KB |
Output is correct |
2 |
Correct |
20 ms |
14592 KB |
Output is correct |
3 |
Correct |
11 ms |
10964 KB |
Output is correct |
4 |
Correct |
13 ms |
12452 KB |
Output is correct |
5 |
Correct |
15 ms |
12744 KB |
Output is correct |
6 |
Correct |
2667 ms |
16588 KB |
Output is correct |
7 |
Correct |
239 ms |
7828 KB |
Output is correct |
8 |
Correct |
935 ms |
12192 KB |
Output is correct |
9 |
Correct |
1135 ms |
12808 KB |
Output is correct |
10 |
Correct |
3024 ms |
16892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
10964 KB |
Output is correct |
2 |
Correct |
14 ms |
11012 KB |
Output is correct |
3 |
Incorrect |
3005 ms |
16796 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
16584 KB |
Output is correct |
2 |
Correct |
22 ms |
16560 KB |
Output is correct |
3 |
Incorrect |
2545 ms |
15880 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |