답안 #919935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919935 2024-02-01T22:02:27 Z Alebn Nautilus (BOI19_nautilus) C++14
100 / 100
174 ms 157580 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 2 ms 1016 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 2 ms 1016 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
7 Correct 1 ms 856 KB Output is correct
8 Correct 2 ms 856 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 2 ms 1112 KB Output is correct
13 Correct 1 ms 856 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 856 KB Output is correct
18 Correct 2 ms 860 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 2 ms 1016 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
7 Correct 1 ms 856 KB Output is correct
8 Correct 2 ms 856 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 2 ms 1112 KB Output is correct
13 Correct 1 ms 856 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 856 KB Output is correct
18 Correct 2 ms 860 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 132 ms 157516 KB Output is correct
23 Correct 125 ms 157320 KB Output is correct
24 Correct 124 ms 157496 KB Output is correct
25 Correct 121 ms 157528 KB Output is correct
26 Correct 123 ms 157520 KB Output is correct
27 Correct 165 ms 157580 KB Output is correct
28 Correct 154 ms 157264 KB Output is correct
29 Correct 151 ms 157524 KB Output is correct
30 Correct 156 ms 157520 KB Output is correct
31 Correct 147 ms 157520 KB Output is correct
32 Correct 170 ms 157520 KB Output is correct
33 Correct 172 ms 157516 KB Output is correct
34 Correct 170 ms 157516 KB Output is correct
35 Correct 167 ms 157520 KB Output is correct
36 Correct 174 ms 157520 KB Output is correct