제출 #390802

#제출 시각아이디문제언어결과실행 시간메모리
390802TosakaUCWSajam (COCI18_sajam)C++17
90 / 90
2585 ms5260 KiB
#include <stdio.h>
#include <algorithm>
#include <memory.h>
#include <iostream>

int read(int x = 0, int f = 0, char ch = getchar())
{
	while (ch < '0' or ch > '9')
		f = ch == '-', ch = getchar();
	while ('0' <= ch and ch <= '9')
		x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

const int N = 1e3 + 5;

int n, k;
int a[N][N];

int main()
{
	n = read(), k = read();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
		{
			char ch;
			std::cin >> ch;
			a[i][j] = ch == 'x';
		}
	for (int T = 1; T <= n; T++)
	{
		int cnt = 0;
		for (int i = 1; i <= n; i++)
		{
			cnt = 0;
			for (int j = 1; j <= n; j++) cnt += a[i][j] == 0;
			if (cnt * 2 > n)
				for (int j = 1; j <= n; j++) a[i][j] ^= 1;
		}
		for (int j = 1; j <= n; j++)
		{
			cnt = 0;
			for (int i = 1; i <= n; i++) cnt += a[i][j] == 0;
			if (cnt * 2 > n)
				for (int i = 1; i <= n; i++) a[i][j] ^= 1;
		}
		cnt = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				cnt += a[i][j];
		if (k + cnt >= n * n) return puts("DA"), 0;
	}
	return puts("NE"), 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...