#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000000005
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mid (start+end)/2
#define mod 1000000007
int32_t main(){
faster
int n,k;
cin>>n>>k;
string s[n],ger[n],sor1[n],sor2[n];
int cev=0,xi=0,oi=0,cev1=0;
for(int i=0;i<n;i++){
cin>>s[i];
string f="";
for(int j=0;j<n;j++){
if(s[i][j]=='x'){
f+='o';
}
else f+='x';
}
ger[i]=f;
}
int gec=n*n;
if(gec%2!=0)gec++;
gec/=2;
if(k>=gec){
cout<<"DA"<<'\n';
}
else{
for(int i=0;i<n;i++){
if(ger[i][0]=='o'){
sor1[i]=ger[i];
}
else{
sor1[i]=s[i];
}
/////////////////////
if(ger[0][i]=='o'){
for(int j=0;j<n;j++){
sor2[i][j]=ger[i][j];
}
}
else{
for(int j=0;j<n;j++){
sor2[i][j]=s[i][j];
}
}
}
int gec=OYY;
for(int i=0;i<n;i++){
gec=OYY;
xi=0,oi=0;
for(int j=0;j<n;j++){
if(sor1[j][i]=='x')xi++;
else oi++;
}
gec=min(oi,xi);
cev+=gec;
}
gec=OYY;
for(int i=0;i<n;i++){
gec=OYY;
xi=0,oi=0;
for(int j=0;j<n;j++){
if(sor2[i][j]=='x')xi++;
else oi++;
}
gec=min(xi,oi);
cev1+=gec;
}
if(min(cev,cev1)<=k)cout<<"DA"<<'\n';
else cout<<"NE"<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
2900 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
3760 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2268 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
6484 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |