Submission #947592

# Submission time Handle Problem Language Result Execution time Memory
947592 2024-03-16T14:25:22 Z VMaksimoski008 Nautilus (BOI19_nautilus) C++14
66 / 100
172 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

int32_t main() {
    int n, m, K, ans = 0;
    cin >> n >> m >> K;

    char mat[n][m];
    for(int i=0; i<n; i++) 
        for(int j=0; j<m; j++) cin >> mat[i][j];

    string s;
    cin >> s;
    s = "." + s;

    bool dp[K+1][n][m];
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++) dp[0][i][j] = (mat[i][j] == '.');

    for(int i=1; i<=K; i++) {
        for(int r=0; r<n; r++) {
            for(int c=0; c<m; c++) {
                if(mat[r][c] == '#') continue;
                if((s[i] == 'W' || s[i] == '?') && c + 1 < m && dp[i-1][r][c+1]) dp[i][r][c] = 1;
                if((s[i] == 'E' || s[i] == '?') && c - 1 >= 0 && dp[i-1][r][c-1]) dp[i][r][c] = 1;
                if((s[i] == 'N' || s[i] == '?') && r + 1 < n && dp[i-1][r+1][c]) dp[i][r][c] = 1;
                if((s[i] == 'S' || s[i] == '?') && r - 1 >= 0 && dp[i-1][r-1][c]) dp[i][r][c] = 1;
            }
        }
    }

    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++) ans += dp[K][i][j];
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 5 ms 1276 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 5 ms 1320 KB Output is correct
5 Correct 3 ms 1368 KB Output is correct
6 Correct 2 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 5 ms 1276 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 5 ms 1320 KB Output is correct
5 Correct 3 ms 1368 KB Output is correct
6 Correct 2 ms 1372 KB Output is correct
7 Correct 5 ms 1372 KB Output is correct
8 Correct 8 ms 1368 KB Output is correct
9 Correct 6 ms 1212 KB Output is correct
10 Correct 4 ms 1372 KB Output is correct
11 Correct 2 ms 1372 KB Output is correct
12 Correct 6 ms 1372 KB Output is correct
13 Correct 10 ms 1212 KB Output is correct
14 Correct 11 ms 1436 KB Output is correct
15 Correct 4 ms 1212 KB Output is correct
16 Correct 2 ms 1368 KB Output is correct
17 Correct 6 ms 1372 KB Output is correct
18 Correct 9 ms 1372 KB Output is correct
19 Correct 11 ms 1444 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 5 ms 1276 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 5 ms 1320 KB Output is correct
5 Correct 3 ms 1368 KB Output is correct
6 Correct 2 ms 1372 KB Output is correct
7 Correct 5 ms 1372 KB Output is correct
8 Correct 8 ms 1368 KB Output is correct
9 Correct 6 ms 1212 KB Output is correct
10 Correct 4 ms 1372 KB Output is correct
11 Correct 2 ms 1372 KB Output is correct
12 Correct 6 ms 1372 KB Output is correct
13 Correct 10 ms 1212 KB Output is correct
14 Correct 11 ms 1436 KB Output is correct
15 Correct 4 ms 1212 KB Output is correct
16 Correct 2 ms 1368 KB Output is correct
17 Correct 6 ms 1372 KB Output is correct
18 Correct 9 ms 1372 KB Output is correct
19 Correct 11 ms 1444 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Runtime error 172 ms 262144 KB Execution killed with signal 9
23 Halted 0 ms 0 KB -