답안 #1039680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039680 2024-07-31T07:30:14 Z 중국공산당(#11033) Toy (CEOI24_toy) C++17
0 / 100
3 ms 5468 KB
#include <cstdio>
#include <cstdlib>

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];

void f(int y, int 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]) 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++) 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:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d%d%d%d", &w, &h, &k, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%*d%d%d%*d", &y, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:25:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     for (int i = 0; i < h; i++) scanf("%s", a[i]);
      |                                 ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Incorrect 0 ms 2652 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Incorrect 0 ms 2652 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 3 ms 4188 KB Output is correct
5 Correct 3 ms 5468 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 3 ms 4700 KB Output is correct
8 Incorrect 2 ms 3932 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Incorrect 0 ms 2652 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Incorrect 0 ms 2652 KB Output isn't correct
7 Halted 0 ms 0 KB -