# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1039754 |
2024-07-31T08:32:02 Z |
중국공산당(#11033) |
Toy (CEOI24_toy) |
C++17 |
|
743 ms |
1048576 KB |
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int dt[4][2] = { 1, 0, -1, 0, 0, 1, 0, -1 };
int w, h, k, l;
int x, y, gx, gy;
char a[1506][1506];
int sum[1506][1506], b[1506][1506], c[1506][1506], d[1506][1506];
void f(int y, int x) {
b[y][x] = 0;
if (y == gy && x == gx) puts("YES"), exit(0);
for (int t = 0; t < 4; t++) {
int ny = y + dt[t][1], nx = x + dt[t][0];
if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
// if (!b[ny][nx]) continue;
if (y == ny && !c[min(y, ny)][min(x, nx)]) continue;
if (x == nx && !d[min(y, ny)][min(x, nx)]) continue;
f(ny, nx);
}
}
int main() {
scanf("%d%d%d%d", &w, &h, &k, &l);
scanf("%*d%d%d%*d", &y, &x);
for (int i = 0; i < h; i++) scanf("%s", a[i]);
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (a[i][j] == '*') gy = i, gx = j;
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) sum[i][j] = (a[i][j] == 'X') + (i ? sum[i - 1][j] : 0) + (j ? sum[i][j - 1] : 0) - (i && j ? sum[i - 1][j - 1] : 0);
for (int i = 0; i < h - l + 1; i++) for (int j = 0; j < w - k + 1; j++) {
int curr = sum[i + l - 1][j + k - 1] - (i ? sum[i - 1][j + k - 1] : 0) - (j ? sum[i + l - 1][j - 1] : 0) + (i && j ? sum[i - 1][j - 1] : 0);
if (!curr) b[i][j]++, b[i + l][j]--, b[i][j + k]--, b[i + l][j + k]++;
}
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) b[i][j] += (i ? b[i - 1][j] : 0) + (j ? b[i][j - 1] : 0) - (i && j ? b[i - 1][j - 1] : 0);
for (int i = 0; i < h - l + 1; i++) for (int j = 0; j < w - 1; j++) {
int curr = sum[i + l - 1][j + 1] - (i ? sum[i - 1][j + 1] : 0) - (j ? sum[i + l - 1][j - 1] : 0) + (i && j ? sum[i - 1][j - 1] : 0);
if (!curr) c[i][j]++, c[i + l][j]--;
}
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) c[i][j] += (i ? c[i - 1][j] : 0);
for (int i = 0; i < h; i++) for (int j = 0; j < w - k + 1; j++) {
int curr = sum[i + 1][j + k - 1] - (i ? sum[i - 1][j + k - 1] : 0) - (j ? sum[i + 1][j - 1] : 0) + (i && j ? sum[i - 1][j - 1] : 0);
if (!curr) d[i][j]++, d[i][j + k]--;
}
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) d[i][j] += (j ? d[i][j - 1] : 0);
f(y, x);
puts("NO");
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%d%d%d%d", &w, &h, &k, &l);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | scanf("%*d%d%d%*d", &y, &x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:30:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | for (int i = 0; i < h; i++) scanf("%s", a[i]);
| ~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |