Submission #100866

# Submission time Handle Problem Language Result Execution time Memory
100866 2019-03-14T23:39:59 Z Ort Sajam (COCI18_sajam) C++11
90 / 90
117 ms 5340 KB
#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 time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 6 ms 2176 KB Output is correct
3 Correct 8 ms 2688 KB Output is correct
4 Correct 18 ms 4736 KB Output is correct
5 Correct 11 ms 2688 KB Output is correct
6 Correct 7 ms 1792 KB Output is correct
7 Correct 28 ms 2560 KB Output is correct
8 Correct 96 ms 4864 KB Output is correct
9 Correct 5 ms 1300 KB Output is correct
10 Correct 76 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 3840 KB Output is correct
2 Correct 17 ms 4352 KB Output is correct
3 Correct 14 ms 3456 KB Output is correct
4 Correct 13 ms 3200 KB Output is correct
5 Correct 18 ms 4728 KB Output is correct
6 Correct 10 ms 2816 KB Output is correct
7 Correct 17 ms 3840 KB Output is correct
8 Correct 20 ms 3968 KB Output is correct
9 Correct 13 ms 2048 KB Output is correct
10 Correct 117 ms 5248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 4480 KB Output is correct
2 Correct 23 ms 4480 KB Output is correct
3 Correct 12 ms 3328 KB Output is correct
4 Correct 14 ms 3712 KB Output is correct
5 Correct 14 ms 3968 KB Output is correct
6 Correct 25 ms 5120 KB Output is correct
7 Correct 8 ms 2432 KB Output is correct
8 Correct 15 ms 3840 KB Output is correct
9 Correct 76 ms 3884 KB Output is correct
10 Correct 110 ms 5340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 3328 KB Output is correct
2 Correct 12 ms 3328 KB Output is correct
3 Correct 20 ms 5176 KB Output is correct
4 Correct 9 ms 2816 KB Output is correct
5 Correct 11 ms 3328 KB Output is correct
6 Correct 24 ms 5148 KB Output is correct
7 Correct 9 ms 2688 KB Output is correct
8 Correct 14 ms 2944 KB Output is correct
9 Correct 36 ms 3064 KB Output is correct
10 Correct 29 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 5288 KB Output is correct
2 Correct 21 ms 5120 KB Output is correct
3 Correct 22 ms 4864 KB Output is correct
4 Correct 13 ms 3712 KB Output is correct
5 Correct 13 ms 3840 KB Output is correct
6 Correct 16 ms 3840 KB Output is correct
7 Correct 10 ms 2816 KB Output is correct
8 Correct 19 ms 4608 KB Output is correct
9 Correct 29 ms 3328 KB Output is correct
10 Correct 101 ms 5240 KB Output is correct