Submission #97279

#TimeUsernameProblemLanguageResultExecution timeMemory
97279hjc20032003Sajam (COCI18_sajam)C++14
90 / 90
998 ms2312 KiB
#include<bits/stdc++.h> #define inf 0x7fffffff #define GN(x,y) x=min(x,y) #define REP(i,s,t) for(int i=s;i<=t;i++) using namespace std; int n,ans=inf; bool m[1005][1005]; int cal(int a,int b) { int ret=0; REP(i,1,n) if(m[a][i]!=m[b][i]) ret++; return min(ret,n-ret); } bool judge() { REP(i,2,n) if(cal(1,i)>1) return false; return true; } int main() { int k; cin>>n>>k; REP(i,1,n) REP(j,1,n) { char ch; cin>>ch; if(ch=='o') m[i][j]=true; } REP(i,1,n) { int cnt=0; REP(j,1,n) cnt+=cal(i,j); GN(ans,cnt); if(ans<=k) {cout<<"DA"; return 0;} } if(k<n) {cout<<"NE"; return 0;} REP(i,1,n) { m[1][i]=!m[1][i]; if(judge()) {cout<<"DA"; return 0;} m[1][i]=!m[1][i]; } cout<<"NE"; return 0; }
#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...