답안 #221381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221381 2020-04-10T00:54:35 Z Leonardo_Paes Nautilus (BOI19_nautilus) C++17
100 / 100
139 ms 864 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 510;

int r, c, m, ans = 0;

bitset<maxn> dp[maxn], mat[maxn], tfg[maxn];

string s;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cin >> r >> c >> m;

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            char a;
            cin >> a;
            if(a == '.') mat[i][c-j-1] = dp[i][c-j-1] = 1;
        }
    }

    cin >> s;

    for(int j=0; j<s.size(); j++){
        if(s[j] == 'N'){
            for(int i=0; i<r; i++){
                if(i+1 < r) dp[i] = (dp[i+1] & mat[i]);
                else dp[i].reset();
            }
        }
        if(s[j] == 'S'){
            for(int i=r-1; i>=0; i--){
                if(i) dp[i] = (dp[i-1] & mat[i]);
                else dp[i].reset();
            }
        }
        if(s[j] == 'E'){
            for(int i=0; i<r; i++){
                dp[i] = ((dp[i] >> 1) & mat[i]);
            }
        }
        if(s[j] == 'W'){
            for(int i=0; i<r; i++){
                dp[i] = ((dp[i] << 1) & mat[i]);
            }
        }
        if(s[j] == '?'){
            for(int i=0; i<r; i++){
                tfg[i] = (dp[i] << 1)|(dp[i] >> 1);
                if(i) tfg[i] |= dp[i-1];
                if(i+1 < r) tfg[i] |= dp[i+1];
                tfg[i] &= mat[i];
            }
            for(int i=0; i<r; i++){
                dp[i] = tfg[i];
            }
        }
    }

    for(int i=0; i<r; i++) ans += dp[i].count();

    cout << ans << endl;

    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0; j<s.size(); j++){
                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 77 ms 640 KB Output is correct
23 Correct 82 ms 640 KB Output is correct
24 Correct 79 ms 640 KB Output is correct
25 Correct 76 ms 744 KB Output is correct
26 Correct 71 ms 640 KB Output is correct
27 Correct 108 ms 640 KB Output is correct
28 Correct 111 ms 640 KB Output is correct
29 Correct 111 ms 640 KB Output is correct
30 Correct 110 ms 640 KB Output is correct
31 Correct 112 ms 640 KB Output is correct
32 Correct 132 ms 640 KB Output is correct
33 Correct 139 ms 640 KB Output is correct
34 Correct 135 ms 864 KB Output is correct
35 Correct 131 ms 640 KB Output is correct
36 Correct 136 ms 640 KB Output is correct