# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
931442 |
2024-02-21T19:40:01 Z |
rainboy |
여왕벌 (KOI15_queen) |
C |
|
5000 ms |
43844 KB |
#include <stdio.h>
#define N 700
int max(int a, int b) { return a > b ? a : b; }
int main() {
static char cc[3][3][3][N][N];
static int ans[N][N + 1];
int n, k, i, j, j1, j2, a, b, c;
scanf("%d%d", &n, &k);
for (i = 1; i < n; i++)
for (j = 1; j < n; j++) {
static char s[28];
scanf("%s", s);
for (a = 0; a < 3; a++)
for (b = 0; b < 3; b++)
for (c = 0; c < 3; c++)
cc[a][b][c][i][j] = s[(a * 3 + b) * 3 + c];
}
while (k--) {
int x, y;
scanf("%d%d%*d", &x, &y), y += x;
j1 = max(x - (n - 1), 0), j2 = max(y - (n - 1), 0);
ans[0][j1]++, ans[0][j2]++;
for (i = 1; i < n; i++) {
if (n - i <= x) {
if (j1 == j2) {
if (j2 == 0 || j2 < n && cc[0][0][2][i][j2] != 'U') {
j2++;
while (j2 < n && cc[0][2][2][i][j2] == 'L')
j2++;
j1 = j2;
}
} else if (j1 == 0 || j1 < n && cc[0][0][1][i][j1] != 'U') {
j1++;
while (j1 < j2 && cc[0][1][1][i][j1] == 'L')
j1++;
if (j1 < j2) {
if (j2 < n && cc[1][1][2][i][j2] != 'U') {
j2++;
while (j2 < n && cc[1][2][2][i][j2] == 'L')
j2++;
}
} else if (j2 < n) {
if (cc[0][1][2][i][j2] == 'L') {
j2++;
while (j2 < n && cc[0][2][2][i][j2] == 'L')
j2++;
j1 = j2;
} else if (cc[0][1][2][i][j2] == 'D') {
j2++;
while (j2 < n && cc[1][2][2][i][j2] == 'L')
j2++;
}
}
} else {
if (j2 < n && cc[1][1][2][i][j2] != 'U') {
j2++;
while (j2 < n && cc[1][2][2][i][j2] == 'L')
j2++;
}
}
} else if (n - i <= y) {
if (j2 == 0 || j2 < n && cc[1][1][2][i][j2] != 'U') {
j2++;
while (j2 < n && cc[1][2][2][i][j2] == 'L')
j2++;
}
}
ans[i][j1]++, ans[i][j2]++;
}
}
for (i = 0; i < n; i++)
for (j = 1; j < n; j++)
ans[i][j] += ans[i][j - 1];
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
ans[i][j]++;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
printf("%d ", ans[i][j]);
printf("\n");
}
return 0;
}
Compilation message
queen.c: In function 'main':
queen.c:32:28: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
32 | if (j2 == 0 || j2 < n && cc[0][0][2][i][j2] != 'U') {
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
queen.c:38:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
38 | } else if (j1 == 0 || j1 < n && cc[0][0][1][i][j1] != 'U') {
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
queen.c:68:27: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
68 | if (j2 == 0 || j2 < n && cc[1][1][2][i][j2] != 'U') {
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
queen.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d%d", &n, &k);
| ^~~~~~~~~~~~~~~~~~~~~
queen.c:17:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | scanf("%s", s);
| ^~~~~~~~~~~~~~
queen.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%d%d%*d", &x, &y), y += x;
| ^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12632 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
4 ms |
13148 KB |
Output is correct |
4 |
Correct |
4 ms |
13404 KB |
Output is correct |
5 |
Correct |
18 ms |
16724 KB |
Output is correct |
6 |
Correct |
18 ms |
16732 KB |
Output is correct |
7 |
Correct |
19 ms |
16752 KB |
Output is correct |
8 |
Correct |
45 ms |
22100 KB |
Output is correct |
9 |
Correct |
47 ms |
22116 KB |
Output is correct |
10 |
Correct |
85 ms |
29444 KB |
Output is correct |
11 |
Correct |
89 ms |
29500 KB |
Output is correct |
12 |
Correct |
91 ms |
29620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12632 KB |
Output is correct |
2 |
Correct |
28 ms |
14416 KB |
Output is correct |
3 |
Correct |
43 ms |
15184 KB |
Output is correct |
4 |
Correct |
125 ms |
17604 KB |
Output is correct |
5 |
Correct |
109 ms |
17592 KB |
Output is correct |
6 |
Correct |
125 ms |
17696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
12636 KB |
Output is correct |
2 |
Correct |
11 ms |
13552 KB |
Output is correct |
3 |
Correct |
103 ms |
23528 KB |
Output is correct |
4 |
Correct |
178 ms |
31312 KB |
Output is correct |
5 |
Correct |
163 ms |
31300 KB |
Output is correct |
6 |
Correct |
163 ms |
31324 KB |
Output is correct |
7 |
Correct |
135 ms |
31212 KB |
Output is correct |
8 |
Correct |
127 ms |
31440 KB |
Output is correct |
9 |
Correct |
122 ms |
31352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2517 ms |
16648 KB |
Output is correct |
2 |
Correct |
1900 ms |
34596 KB |
Output is correct |
3 |
Correct |
3142 ms |
43772 KB |
Output is correct |
4 |
Execution timed out |
5084 ms |
36148 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
1 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Correct |
2 ms |
12636 KB |
Output is correct |
5 |
Correct |
165 ms |
15772 KB |
Output is correct |
6 |
Correct |
176 ms |
15788 KB |
Output is correct |
7 |
Correct |
177 ms |
15652 KB |
Output is correct |
8 |
Correct |
179 ms |
18488 KB |
Output is correct |
9 |
Correct |
2021 ms |
43324 KB |
Output is correct |
10 |
Correct |
3224 ms |
43692 KB |
Output is correct |
11 |
Correct |
2295 ms |
43844 KB |
Output is correct |
12 |
Execution timed out |
5005 ms |
36028 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |