Submission #947631

# Submission time Handle Problem Language Result Execution time Memory
947631 2024-03-16T16:49:09 Z VMaksimoski008 Nautilus (BOI19_nautilus) C++14
100 / 100
159 ms 776 KB
#include <bits/stdc++.h>
using namespace std;

bitset<500> dp[2][500], mat[500];

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

    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            char ch; cin >> ch;
            mat[i][j] = (ch == '.');
        }
    }

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

    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++) {
            if(s[i] == 'W' || s[i] == '?') dp[1][r] |= (mat[r] & (dp[0][r] >> 1));
            if(s[i] == 'E' || s[i] == '?') dp[1][r] |= (mat[r] & (dp[0][r] << 1));
            if((s[i] == 'N' || s[i] == '?') && r + 1 < n) dp[1][r] |= (dp[0][r+1] & mat[r]);
            if((s[i] == 'S' || s[i] == '?') && r - 1 >= 0) dp[1][r] |= (dp[0][r-1] & mat[r]);
        }
        
        for(int r=0; r<n; r++) {
            dp[0][r] = dp[1][r];
            dp[1][r].reset();
        }
    }

    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++) ans += dp[0][i][j];
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 83 ms 444 KB Output is correct
23 Correct 85 ms 772 KB Output is correct
24 Correct 91 ms 604 KB Output is correct
25 Correct 83 ms 600 KB Output is correct
26 Correct 82 ms 600 KB Output is correct
27 Correct 120 ms 604 KB Output is correct
28 Correct 125 ms 776 KB Output is correct
29 Correct 121 ms 604 KB Output is correct
30 Correct 125 ms 772 KB Output is correct
31 Correct 142 ms 600 KB Output is correct
32 Correct 157 ms 768 KB Output is correct
33 Correct 150 ms 600 KB Output is correct
34 Correct 153 ms 600 KB Output is correct
35 Correct 159 ms 772 KB Output is correct
36 Correct 150 ms 600 KB Output is correct