# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1039691 |
2024-07-31T07:41:07 Z |
중국공산당(#11033) |
Toy (CEOI24_toy) |
C++17 |
|
5 ms |
8540 KB |
#include <cstdio>
#include <random>
#include <cstdlib>
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];
long long sum[1506][1506], b[1506][1506];
mt19937 gen(1104);
uniform_int_distribution<int> uid(0, 60);
void f(int y, int x) {
long long o = sum[y][x];
sum[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 (!(sum[ny][nx] & o)) 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) {
long long c = 1LL << uid(gen);
b[i][j] += c, b[i + l][j] -= c, b[i][j + k] -= c, b[i + l][j + k] += c;
}
}
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) sum[i][j] = b[i][j] + (i ? sum[i - 1][j] : 0) + (j ? sum[i][j - 1] : 0) - (i && j ? sum[i - 1][j - 1] : 0);
f(y, x);
puts("NO");
}
Compilation message
Main.cpp: In function 'int main()':
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", &w, &h, &k, &l);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | scanf("%*d%d%d%*d", &y, &x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:31:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | for (int i = 0; i < h; i++) scanf("%s", a[i]);
| ~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
5188 KB |
Output is correct |
5 |
Correct |
5 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
5980 KB |
Output is correct |
8 |
Incorrect |
3 ms |
6236 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |