Submission #200585

#TimeUsernameProblemLanguageResultExecution timeMemory
200585AsrapogorgonSajam (COCI18_sajam)C++14
45 / 90
362 ms1016 KiB
#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; int coun=0; for(int i=0;i<n;i++){ int u=0; for(int j=0;j<n;j++){ char a; cin>>a; bit[i][j]=(a=='x'); u+=bit[i][j]; } coun+=min(u,n-u); } if(coun<=k){ cout<<YES<<endl; return 0; } 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++){ 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...