Submission #147350

# Submission time Handle Problem Language Result Execution time Memory
147350 2019-08-29T07:31:02 Z georgerapeanu Nautilus (BOI19_nautilus) C++11
100 / 100
184 ms 816 KB
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

bitset<505> dp[2][505];
bitset<505> base[505];

int r,c,m;
string s;

int main(){

    cin >> r >> c >> m;
    
    for(int i = 1;i <= r;i++){
        cin >> s;
        s = " " + s;
        for(int j = 1;j <= c;j++){
            base[i][j] = (s[j] == '.');
        }
        dp[0][i] = base[i];
    }
    
    cin >> s;
    s = " " + s;

    for(int l = 1,k = 1;k <= m;l ^= 1,k++){
        for(int i = 1;i <= r;i++){
            dp[l][i].reset();
            if(s[k] == 'N' || s[k] == '?'){
                dp[l][i] |= dp[l ^ 1][i + 1];
            }
            if(s[k] == 'S' || s[k] == '?'){
                dp[l][i] |= dp[l ^ 1][i - 1];
            }
            if(s[k] == 'E' || s[k] == '?'){
                dp[l][i] |= (dp[l ^ 1][i] << 1);
            }
            if(s[k] == 'W' || s[k] == '?'){
                dp[l][i] |= (dp[l ^ 1][i] >> 1);
            }
            dp[l][i] &= base[i];
        }
    }

    int ans = 0;

    for(int i = 1;i <= r;i++){
        for(int j = 1;j <= c;j++){
            ans += (dp[m & 1][i][j]);
        }
    }

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 109 ms 376 KB Output is correct
23 Correct 111 ms 816 KB Output is correct
24 Correct 108 ms 632 KB Output is correct
25 Correct 109 ms 804 KB Output is correct
26 Correct 107 ms 784 KB Output is correct
27 Correct 149 ms 632 KB Output is correct
28 Correct 151 ms 716 KB Output is correct
29 Correct 152 ms 760 KB Output is correct
30 Correct 153 ms 720 KB Output is correct
31 Correct 150 ms 716 KB Output is correct
32 Correct 183 ms 760 KB Output is correct
33 Correct 184 ms 632 KB Output is correct
34 Correct 183 ms 720 KB Output is correct
35 Correct 183 ms 632 KB Output is correct
36 Correct 183 ms 812 KB Output is correct