답안 #919936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919936 2024-02-01T22:03:06 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
176 ms 157324 KB
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#define N 500

using namespace std;

int n, m, len;
string s;

bool check(int i, int j) {
    if(i > -1 && j > -1 && i < n && j < m) return true;
    return false;
}

int main() {
    cin >> n >> m >> len;
    vector<bitset<N>> a(n, bitset<N>());
    for(int i = 0; i < n; i++) {
        cin >> s;
        for(int j = 0; j < m; j++) {
            if(s[j] == '.') a[i][j] = 1;
        }
    }
    cin >> s;
    //dp
    vector<vector<bitset<N>>> dp(len+1, vector<bitset<N>>(n, bitset<N>()));
    //base case
    for(int i = 0; i < n; i++) dp[0][i] = a[i];
    //transition
    for(int k = 1; k <= len; k++) {
        for(int i = 0; i < n; i++) {
            if((s[k-1] == 'N' || s[k-1] == '?') && i < n-1) dp[k][i] |= dp[k-1][i+1];
            if(s[k-1] == 'E' || s[k-1] == '?') {
                dp[k][i] |= (dp[k-1][i]<<1);
            }
            if((s[k-1] == 'S' || s[k-1] == '?') && i > 0) dp[k][i] |= dp[k-1][i-1];
            if(s[k-1] == 'W' || s[k-1] == '?') dp[k][i] |= (dp[k-1][i]>>1);
            dp[k][i] &= a[i];
        }
    }
    //final state
    int res = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) res += dp[len][i][j];
    }
    cout << res << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 856 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 856 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 1060 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 856 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 856 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 856 KB Output is correct
19 Correct 1 ms 856 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 856 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 1060 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 856 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 856 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 856 KB Output is correct
19 Correct 1 ms 856 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 856 KB Output is correct
22 Correct 122 ms 157264 KB Output is correct
23 Correct 128 ms 157264 KB Output is correct
24 Correct 123 ms 157264 KB Output is correct
25 Correct 131 ms 157268 KB Output is correct
26 Correct 124 ms 157268 KB Output is correct
27 Correct 148 ms 157264 KB Output is correct
28 Correct 159 ms 157264 KB Output is correct
29 Correct 148 ms 157048 KB Output is correct
30 Correct 154 ms 157324 KB Output is correct
31 Correct 145 ms 157264 KB Output is correct
32 Correct 168 ms 157264 KB Output is correct
33 Correct 176 ms 157268 KB Output is correct
34 Correct 168 ms 157264 KB Output is correct
35 Correct 176 ms 157184 KB Output is correct
36 Correct 168 ms 157272 KB Output is correct