Submission #959690

# Submission time Handle Problem Language Result Execution time Memory
959690 2024-04-08T19:45:28 Z Blagoj Nautilus (BOI19_nautilus) C++17
100 / 100
119 ms 824 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll long long
#define all(x) (x).begin(), (x).end()

const int mxn = 510;

bitset<mxn> dp[mxn][2], v[mxn];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) v[i][j] = (s[j] == '.');
    }
    for (int i = 0; i < n; i++) dp[i][0] = v[i];
    string s;
    cin >> s;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n; j++) dp[j][1] = dp[j][0];
        if (s[i] == 'N') {
            dp[n - 1][0] = 0;
            for (int j = 0; j < n - 1; j++) dp[j][0] = dp[j + 1][1];
        }
        if (s[i] == 'E') {
            for (int j = 0; j < n; j++) dp[j][0] = (dp[j][1] << 1);
        }
        if (s[i] == 'S') {
            dp[0][0] = 0; 
            for (int j = 1; j < n; j++) dp[j][0] = dp[j - 1][1];
        }
        if (s[i] == 'W') {
            for (int j = 0; j < n; j++) dp[j][0] = (dp[j][1] >> 1);
        }
        if (s[i] == '?') {
            dp[n - 1][0] = 0;
            for (int j = 0; j < n - 1; j++) dp[j][0] = dp[j + 1][1];
            for (int j = 0; j < n; j++) dp[j][0] |= (dp[j][1] << 1);
            for (int j = 1; j < n; j++) dp[j][0] |= dp[j - 1][1];
            for (int j = 0; j < n; j++) dp[j][0] |= (dp[j][1] >> 1);
        }
        for (int j = 0; j < n; j++) dp[j][0] &= v[j];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += dp[i][0].count();
    cout << ans; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 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 756 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 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 344 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 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 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 756 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 54 ms 604 KB Output is correct
23 Correct 58 ms 604 KB Output is correct
24 Correct 54 ms 800 KB Output is correct
25 Correct 50 ms 600 KB Output is correct
26 Correct 51 ms 724 KB Output is correct
27 Correct 93 ms 804 KB Output is correct
28 Correct 92 ms 824 KB Output is correct
29 Correct 90 ms 600 KB Output is correct
30 Correct 95 ms 808 KB Output is correct
31 Correct 90 ms 804 KB Output is correct
32 Correct 116 ms 812 KB Output is correct
33 Correct 114 ms 756 KB Output is correct
34 Correct 119 ms 800 KB Output is correct
35 Correct 115 ms 600 KB Output is correct
36 Correct 117 ms 812 KB Output is correct