답안 #1000079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000079 2024-06-16T15:30:48 Z KactusJack Nautilus (BOI19_nautilus) C++17
100 / 100
177 ms 157524 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k;
    cin >> n >> m >> k;
    vector<bitset<500>> row(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char c;
            cin >> c;
            if(c == '.'){
                row[i][j] = 1;
            }
        }
    }
    string s;
    cin >> s;
    vector<vector<bitset<500>>> dp(k+1, vector<bitset<500>> (n));
    for(int i = 0; i < n; i++){
        dp[0][i] = row[i];
    }
    for(int x = 1; x <= k; x++){
        for(int i = 0; i < n; i++){
            if(s[x-1] == 'E'){
                dp[x][i] = (dp[x-1][i]<<1)&row[i];
            }
            else if(s[x-1] == 'W'){
                dp[x][i] = (dp[x-1][i]>>1)&row[i];
            }
            else if(s[x-1] == 'N' && i+1 < n){
                dp[x][i] = dp[x-1][i+1]&row[i];
            }
            else if(s[x-1] == 'S' && i-1 >= 0){
                dp[x][i] = dp[x-1][i-1]&row[i];
            }
            else if(s[x-1] == '?'){
                dp[x][i] |= (dp[x-1][i]<<1);
                dp[x][i] |= (dp[x-1][i]>>1);
                if(i+1 < n){
                    dp[x][i] |= dp[x-1][i+1];
                }
                if(i-1 >= 0){
                    dp[x][i] |= dp[x-1][i-1];
                }
                dp[x][i] &= row[i];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += dp[k][i].count();
    }
    cout << ans;
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 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 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 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 860 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 860 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 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 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 860 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 860 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 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 125 ms 157520 KB Output is correct
23 Correct 135 ms 157508 KB Output is correct
24 Correct 129 ms 157428 KB Output is correct
25 Correct 123 ms 157524 KB Output is correct
26 Correct 151 ms 157380 KB Output is correct
27 Correct 149 ms 157404 KB Output is correct
28 Correct 158 ms 157520 KB Output is correct
29 Correct 150 ms 157524 KB Output is correct
30 Correct 154 ms 157524 KB Output is correct
31 Correct 149 ms 157344 KB Output is correct
32 Correct 171 ms 157520 KB Output is correct
33 Correct 169 ms 157416 KB Output is correct
34 Correct 172 ms 157524 KB Output is correct
35 Correct 177 ms 157404 KB Output is correct
36 Correct 168 ms 157520 KB Output is correct