#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];
int cev=0,xi=0,oi=0,cev1=0,cev2=0,cev3=0,oim=0,xim=0,gec2=OYY,tr=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';
tr++;
}
else f+='x';
}
ger[i]=f;
}
int gec=n*n;
if(gec%2!=0)gec++;
gec/=2;
cout<<gec<<endl;
if(tr==n*n/2 && n%2==0){
cout<<"DA"<<'\n';;
}
else 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];
}
}
int gec=OYY;
for(int i=0;i<n;i++){
gec=OYY;
gec2=OYY;
xi=0,oi=0;
oim=0,xim=0;
for(int j=0;j<n;j++){
if(sor1[j][i]=='x')xi++;
else oi++;
}
for(int j=0;j<n;j++){
if(sor1[i][j]=='x')xim++;
else oim++;
}
gec=min(oi,xi);
gec2=min(oim,xim);
cev+=gec;
cev1+=gec2;
}
for(int i=0;i<n;i++){
if(ger[0][i]=='o'){
for(int j=0;j<n;j++){
sor1[j][i]=ger[j][i];
}
}
else{
for(int j=0;j<n;j++){
sor1[j][i]=s[j][i];
}
}
}
gec=OYY;
for(int i=0;i<n;i++){
gec=OYY;
gec2=OYY;
xi=0,oi=0;
for(int j=0;j<n;j++){
if(sor1[i][j]=='x')xi++;
else oi++;
}
for(int j=0;j<n;j++){
if(sor1[j][i]=='x')xim++;
else oim++;
}
gec=min(xi,oi);
gec2=min(xim,oim);
cev2+=gec;
cev3+=gec2;
}
int sonuc=min(cev,min(cev1,min(cev2,cev3)));
if(sonuc<=k)cout<<"DA"<<'\n';
else cout<<"NE"<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
4180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |