This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
char t;
cin>>t;
bit[i][j]=(t=='o');
}
}
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++){
b[i]=(1-b[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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |