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 int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define N 200010
int cnt[N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,i,k,j;
cin>>n>>k;
string s;
for(j=0;j<n;j++){
cin>>s;
int r1=0,r2=0,r=0;
for(i=0;i<n;i++){
int x=(s[i]=='o'?1:0);
r1+=min(j-cnt[i]-x,cnt[i]+x);
r2+=min(j-cnt[i]-(x^1),cnt[i]+(x^1));
}
if(r1>r2)r=1;
for(i=0;i<n;i++){
int x=(s[i]=='o'?1:0)^r;
cnt[i]+=x;
}
}
int ans=0;
for(i=0;i<n;i++)ans+=min(n-cnt[i],cnt[i]);
cout<<(ans<=k?"DA":"NE")<<'\n';
}
# | 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... |