#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000;
const lo li = 1005;
const lo mod = 1000000007;
int n,m,a[li][li],k,flag,t,acik[li],tut[li];
int cev;
string s[li];
vector<int> v;
int main(void){
fio();
cin>>n>>k;
FOR cin>>s[i];
//~ if(k>(n+1)/2){cout<<"DA\n";return 0;}
FOR{
for(int j=0;j<n;j++){
if(s[i][j]=='o')a[i][j]=1;
}
}
//~ for(int ii=1;ii<=n;ii++){
int ii=1;
cev=0;
for(int i=1;i<=n;i++){
if(i==ii)continue;
int say=0;
for(int j=0;j<n;j++){
if((a[ii][j]^a[i][j]))say++;
}
tut[i]=say;
cev+=min(say,n-say);
//~ cout<<i<<" ()() "<<cev<<endl;
}
v.clear();
for(int j=0;j<n;j++){
int yes=0;
for(int i=1;i<=n;i++){
if(i==ii)continue;
if(a[ii][j]!=a[i][j]){
if(tut[i]>=n-tut[i])yes--;
else yes++;
}
else{
if(tut[i]>n-tut[i])yes++;
else yes--;
}
}
v.pb(yes);
}
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
int sayac=0,say2=0;
if(cev<=k){cout<<"DA\n";return 0;}
for(auto go:v){
sayac++;
say2+=go;
//~ cout<<say2<<" :: "<<sayac<<" :: "<<cev<<endl;
if(cev-say2<=k){cout<<"DA\n";return 0;}
}
//~ }
cout<<"NE\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
2 ms |
3188 KB |
Output is correct |
4 |
Correct |
6 ms |
5720 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
4 ms |
3184 KB |
Output is correct |
8 |
Correct |
14 ms |
5716 KB |
Output is correct |
9 |
Correct |
2 ms |
2648 KB |
Output is correct |
10 |
Correct |
15 ms |
5980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
5 ms |
4952 KB |
Output is correct |
3 |
Correct |
3 ms |
3928 KB |
Output is correct |
4 |
Correct |
3 ms |
3676 KB |
Output is correct |
5 |
Correct |
8 ms |
5724 KB |
Output is correct |
6 |
Correct |
3 ms |
3164 KB |
Output is correct |
7 |
Correct |
4 ms |
4444 KB |
Output is correct |
8 |
Correct |
4 ms |
4700 KB |
Output is correct |
9 |
Correct |
3 ms |
2908 KB |
Output is correct |
10 |
Correct |
16 ms |
6216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
5212 KB |
Output is correct |
2 |
Correct |
5 ms |
5364 KB |
Output is correct |
3 |
Correct |
3 ms |
3676 KB |
Output is correct |
4 |
Correct |
4 ms |
4444 KB |
Output is correct |
5 |
Correct |
4 ms |
4444 KB |
Output is correct |
6 |
Correct |
6 ms |
6112 KB |
Output is correct |
7 |
Correct |
2 ms |
2908 KB |
Output is correct |
8 |
Correct |
4 ms |
4388 KB |
Output is correct |
9 |
Correct |
10 ms |
4444 KB |
Output is correct |
10 |
Correct |
17 ms |
6376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3676 KB |
Output is correct |
2 |
Correct |
3 ms |
3872 KB |
Output is correct |
3 |
Correct |
6 ms |
6164 KB |
Output is correct |
4 |
Correct |
2 ms |
3164 KB |
Output is correct |
5 |
Correct |
3 ms |
3876 KB |
Output is correct |
6 |
Correct |
6 ms |
5976 KB |
Output is correct |
7 |
Correct |
2 ms |
3164 KB |
Output is correct |
8 |
Correct |
2 ms |
3164 KB |
Output is correct |
9 |
Correct |
6 ms |
3504 KB |
Output is correct |
10 |
Correct |
5 ms |
3164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
6232 KB |
Output is correct |
2 |
Correct |
6 ms |
6236 KB |
Output is correct |
3 |
Correct |
6 ms |
5720 KB |
Output is correct |
4 |
Correct |
4 ms |
4188 KB |
Output is correct |
5 |
Correct |
4 ms |
4440 KB |
Output is correct |
6 |
Correct |
4 ms |
4440 KB |
Output is correct |
7 |
Correct |
3 ms |
3160 KB |
Output is correct |
8 |
Correct |
5 ms |
5468 KB |
Output is correct |
9 |
Correct |
7 ms |
3772 KB |
Output is correct |
10 |
Correct |
15 ms |
5980 KB |
Output is correct |