Submission #529670

# Submission time Handle Problem Language Result Execution time Memory
529670 2022-02-23T10:34:43 Z c28dnv9q3 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 972 KB
#include <stdio.h>

char grid[505][505];
bool dp[2][505][505];

int main() {
    int R, C, M;
    scanf("%d %d %d", &R, &C, &M);

    for(int r = 0; r < R; r++) {
        for(int c = 0; c < C; c++) {
            for(grid[r][c] = getchar(); grid[r][c] != '.' && grid[r][c] != '#'; grid[r][c] = getchar());
            dp[0][r][c] = (grid[r][c] == '.');
        }
    }

    int g = 1, pg = 0;
    for(int i = 0; i < M; i++) {
        char m;
        for(m = getchar();
            m != 'N' &&
            m != 'E' &&
            m != 'S' &&
            m != 'W' &&
            m != '?'
        ; m = getchar());

        for(int r = 0; r < R; r++) {
            for(int c = 0; c < C; c++) {
                dp[g][r][c] = false;
                if(grid[r][c] != '.') continue;
                if((m == '?' || m == 'N') && r < R-1) dp[g][r][c] |= dp[pg][r+1][c];
                if((m == '?' || m == 'E') && c > 0)   dp[g][r][c] |= dp[pg][r][c-1];
                if((m == '?' || m == 'S') && r > 0)   dp[g][r][c] |= dp[pg][r-1][c];
                if((m == '?' || m == 'W') && c < C-1) dp[g][r][c] |= dp[pg][r][c+1];
            }
        }
        pg = g;
        g = (g+1) % 2;
    }

    int pc = 0;
    for(int r = 0; r < R; r++) {
        for(int c = 0; c < C; c++) {
            if(dp[pg][r][c]) pc++;
        }
    }
    printf("%d\n", pc);

    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d %d", &R, &C, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 5 ms 432 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 5 ms 432 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
8 Correct 6 ms 432 KB Output is correct
9 Correct 5 ms 332 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 4 ms 432 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 6 ms 332 KB Output is correct
18 Correct 7 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 5 ms 432 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
8 Correct 6 ms 432 KB Output is correct
9 Correct 5 ms 332 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 4 ms 432 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 6 ms 332 KB Output is correct
18 Correct 7 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Execution timed out 1080 ms 972 KB Time limit exceeded
23 Halted 0 ms 0 KB -