답안 #100867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100867 2019-03-14T23:42:50 Z Ort Sajam (COCI18_sajam) C++11
90 / 90
143 ms 4352 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 6 ms 2048 KB Output is correct
3 Correct 7 ms 2432 KB Output is correct
4 Correct 19 ms 3968 KB Output is correct
5 Correct 8 ms 2432 KB Output is correct
6 Correct 4 ms 1664 KB Output is correct
7 Correct 26 ms 2304 KB Output is correct
8 Correct 121 ms 3968 KB Output is correct
9 Correct 6 ms 1280 KB Output is correct
10 Correct 69 ms 3968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 768 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 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3328 KB Output is correct
2 Correct 17 ms 3712 KB Output is correct
3 Correct 11 ms 3072 KB Output is correct
4 Correct 11 ms 2944 KB Output is correct
5 Correct 25 ms 3980 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 15 ms 3456 KB Output is correct
8 Correct 16 ms 3456 KB Output is correct
9 Correct 13 ms 1920 KB Output is correct
10 Correct 143 ms 4224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3712 KB Output is correct
2 Correct 18 ms 3712 KB Output is correct
3 Correct 30 ms 2944 KB Output is correct
4 Correct 13 ms 3200 KB Output is correct
5 Correct 16 ms 3328 KB Output is correct
6 Correct 23 ms 4096 KB Output is correct
7 Correct 7 ms 2176 KB Output is correct
8 Correct 14 ms 3200 KB Output is correct
9 Correct 76 ms 3328 KB Output is correct
10 Correct 106 ms 4220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2944 KB Output is correct
2 Correct 10 ms 2944 KB Output is correct
3 Correct 24 ms 4224 KB Output is correct
4 Correct 11 ms 2432 KB Output is correct
5 Correct 10 ms 2916 KB Output is correct
6 Correct 22 ms 4216 KB Output is correct
7 Correct 8 ms 2432 KB Output is correct
8 Correct 9 ms 2560 KB Output is correct
9 Correct 28 ms 2560 KB Output is correct
10 Correct 29 ms 2560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 4352 KB Output is correct
2 Correct 19 ms 4224 KB Output is correct
3 Correct 18 ms 4172 KB Output is correct
4 Correct 12 ms 3200 KB Output is correct
5 Correct 13 ms 3200 KB Output is correct
6 Correct 17 ms 3328 KB Output is correct
7 Correct 11 ms 2560 KB Output is correct
8 Correct 26 ms 3832 KB Output is correct
9 Correct 32 ms 2944 KB Output is correct
10 Correct 126 ms 4096 KB Output is correct