답안 #147351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147351 2019-08-29T07:33:11 Z georgerapeanu Nautilus (BOI19_nautilus) C++11
100 / 100
95 ms 572 KB
#pragma GCC optimize("Ofast")
#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;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 67 ms 520 KB Output is correct
23 Correct 68 ms 468 KB Output is correct
24 Correct 67 ms 480 KB Output is correct
25 Correct 66 ms 380 KB Output is correct
26 Correct 65 ms 380 KB Output is correct
27 Correct 81 ms 504 KB Output is correct
28 Correct 82 ms 376 KB Output is correct
29 Correct 82 ms 496 KB Output is correct
30 Correct 83 ms 376 KB Output is correct
31 Correct 81 ms 376 KB Output is correct
32 Correct 94 ms 504 KB Output is correct
33 Correct 94 ms 376 KB Output is correct
34 Correct 95 ms 464 KB Output is correct
35 Correct 94 ms 572 KB Output is correct
36 Correct 93 ms 464 KB Output is correct