#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
15 ms |
2096 KB |
Output is correct |
3 |
Correct |
18 ms |
2468 KB |
Output is correct |
4 |
Correct |
55 ms |
4664 KB |
Output is correct |
5 |
Correct |
19 ms |
2532 KB |
Output is correct |
6 |
Correct |
8 ms |
1612 KB |
Output is correct |
7 |
Correct |
317 ms |
2480 KB |
Output is correct |
8 |
Correct |
2182 ms |
4792 KB |
Output is correct |
9 |
Correct |
36 ms |
1228 KB |
Output is correct |
10 |
Correct |
2167 ms |
4832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
668 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
460 KB |
Output is correct |
7 |
Correct |
3 ms |
568 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
2 ms |
588 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
3700 KB |
Output is correct |
2 |
Correct |
51 ms |
4180 KB |
Output is correct |
3 |
Correct |
32 ms |
3360 KB |
Output is correct |
4 |
Correct |
28 ms |
3148 KB |
Output is correct |
5 |
Correct |
54 ms |
4580 KB |
Output is correct |
6 |
Correct |
394 ms |
2688 KB |
Output is correct |
7 |
Correct |
1095 ms |
3752 KB |
Output is correct |
8 |
Correct |
1203 ms |
4036 KB |
Output is correct |
9 |
Correct |
201 ms |
1996 KB |
Output is correct |
10 |
Correct |
2560 ms |
5260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
4360 KB |
Output is correct |
2 |
Correct |
50 ms |
4376 KB |
Output is correct |
3 |
Correct |
28 ms |
3248 KB |
Output is correct |
4 |
Correct |
37 ms |
3652 KB |
Output is correct |
5 |
Correct |
38 ms |
3724 KB |
Output is correct |
6 |
Correct |
2390 ms |
5060 KB |
Output is correct |
7 |
Correct |
275 ms |
2380 KB |
Output is correct |
8 |
Correct |
979 ms |
3628 KB |
Output is correct |
9 |
Correct |
1153 ms |
3820 KB |
Output is correct |
10 |
Correct |
2499 ms |
5144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
3148 KB |
Output is correct |
2 |
Correct |
29 ms |
3272 KB |
Output is correct |
3 |
Correct |
65 ms |
5000 KB |
Output is correct |
4 |
Correct |
21 ms |
2688 KB |
Output is correct |
5 |
Correct |
29 ms |
3268 KB |
Output is correct |
6 |
Correct |
2585 ms |
4996 KB |
Output is correct |
7 |
Correct |
381 ms |
2760 KB |
Output is correct |
8 |
Correct |
467 ms |
2816 KB |
Output is correct |
9 |
Correct |
494 ms |
2872 KB |
Output is correct |
10 |
Correct |
441 ms |
2756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
5188 KB |
Output is correct |
2 |
Correct |
64 ms |
4932 KB |
Output is correct |
3 |
Correct |
57 ms |
4808 KB |
Output is correct |
4 |
Correct |
35 ms |
3592 KB |
Output is correct |
5 |
Correct |
37 ms |
3656 KB |
Output is correct |
6 |
Correct |
1115 ms |
3808 KB |
Output is correct |
7 |
Correct |
417 ms |
2704 KB |
Output is correct |
8 |
Correct |
1759 ms |
4480 KB |
Output is correct |
9 |
Correct |
697 ms |
3216 KB |
Output is correct |
10 |
Correct |
2380 ms |
4948 KB |
Output is correct |