답안 #1060763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060763 2024-08-15T22:12:15 Z qlu11708 Toy (CEOI24_toy) C++14
0 / 100
1 ms 4444 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1504;
bool vis[N][N];
int lleft[N][N], rright[N][N], ttop[N][N], bbottom[N][N];
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int h, w, k, l;

void dfs(int x, int y) {
    vis[x][y] = 1;
    // printf("(%d, `%d)\n", x, y);
    for (int z = 0; z < 4; z++) {
        int a = x + dx[z], b = y + dy[z];
        if (a <= h && a >= 1 && b <= w && b >= 1 && !vis[a][b] && lleft[a][b]) {
            if (z < 2 && (min(lleft[x][y], lleft[a][b]) + min(rright[x][y], rright[a][b]) >= k)) {
                dfs(a, b);
            }
            if (z > 1 && (min(ttop[x][y], ttop[a][b]) + min(bbottom[x][y], bbottom[a][b]) >= l)) {
                dfs(a, b);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> w >> h >> k >> l;
    int xh, yh, xv, yv; cin >> xh >> yh >> xv >> yv;
    int x = xh, y = yv, xend, yend;
    x++; y++;
    vector<vector<char>> grid(h + 1, vector<char>(w + 1));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '*') {
                xend = i;
                yend = j;
            }
        }
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (grid[i][j] == 'X') {
                lleft[i][j] = ttop[i][j] = 0;
                continue;
            }
            lleft[i][j] = lleft[i][j - 1] + 1;
            ttop[i][j] = ttop[i - 1][j] + 1;
        }
    }
    for (int i = h; i >= 1; i--) {
        for (int j = w; j >= 1; j--) {
            if (grid[i][j] == 'X') {
                rright[i][j] = bbottom[i][j] = 0;
                continue;
            }
            rright[i][j] = rright[i][j + 1] + 1;
            bbottom[i][j] = bbottom[i + 1][j] + 1;
        }
    }
    dfs(x, y);
    cout << (vis[xend][yend] ? "YES" : "NO") << "\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:65:28: warning: 'yend' may be used uninitialized in this function [-Wmaybe-uninitialized]
   65 |     cout << (vis[xend][yend] ? "YES" : "NO") << "\n";
      |              ~~~~~~~~~~~~~~^
Main.cpp:65:28: warning: 'xend' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3160 KB Output is correct
6 Incorrect 1 ms 3164 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3160 KB Output is correct
6 Incorrect 1 ms 3164 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 1 ms 2908 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3160 KB Output is correct
6 Incorrect 1 ms 3164 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3160 KB Output is correct
6 Incorrect 1 ms 3164 KB Output isn't correct
7 Halted 0 ms 0 KB -