Submission #100866

#TimeUsernameProblemLanguageResultExecution timeMemory
100866OrtSajam (COCI18_sajam)C++11
90 / 90
117 ms5340 KiB
#include<iostream> #include<vector> #include<string> #define MAX 1010 using namespace std; int n, k; int mat[MAX][MAX]; char x; void load() { for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { cin >> x; x=='x'?mat[i][j]=0:mat[i][j]=1; } } } int count() { int ret = 0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { ret += mat[i][j]; } } return ret; } void solve() { int half = n/2; int ltotal = count(); for(int i=0;i<n;i++) { int cntr = 0; for(int j=0;j<n;j++) { cntr += mat[i][j]; } if(cntr>=half) { for(int j=0;j<n;j++) { mat[i][j] ^= 1; } } } for(int i=0;i<n;i++) { int cntr = 0; for(int j=0;j<n;j++) { cntr += mat[j][i]; } if(cntr>=half) { for(int j=0;j<n;j++) { mat[j][i] ^= 1; } } } int ntotal = count(); if(ntotal<=k) { cout << "DA"; } else { if(ntotal<ltotal) { solve(); } else { cout << "NE"; } } } int main() { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); cin >> n >> k; load(); solve(); 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...