Submission #200582

#TimeUsernameProblemLanguageResultExecution timeMemory
200582AsrapogorgonSajam (COCI18_sajam)C++14
45 / 90
163 ms1560 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=1e3+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 cnt=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]; } cnt+=min(u,n-u); } if(cnt<=k){ cout<<YES<<endl; return 0; } bitset<maxn>b=bit[0]; for(int i=0;i<n;i++){ int tmp=0; for(int j=0;j<n;j++){ int cn=(bit[j]^b).count(); cn=min(cn,n-cn); tmp+=cn; } if(tmp<=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...