답안 #813528

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
813528 2023-08-07T19:40:42 Z bane Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 14292 KB
//#include<iostream>
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast,unroll-loops")

using namespace std;


const int nax = 501;
char grid[nax][nax];

vector<vector<vector<int>>>dp(nax,vector<vector<int>>(nax,vector<int>(2, 0)));

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> grid[i][j];
        }
    }

    string s;
    cin >> s;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            dp[i][j][0] = (grid[i][j] == '.' ? 1 : 0);
        }
    }
    for (int t = 1; t <= k; t++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                if (grid[i][j] == '#')continue;
                dp[i][j][t % 2] = 0;
                if (s[t - 1] == 'N' || s[t - 1] == '?'){
                    if (i != n - 1)dp[i][j][t % 2] |= dp[i + 1][j][!(t % 2)];
                }
                if (s[t - 1] == 'S' || s[t - 1] == '?'){
                    if (i)dp[i][j][t % 2] |= dp[i - 1][j][!(t % 2)];
                }

                if (s[t - 1] == 'E' || s[t - 1] == '?'){
                    if (j)dp[i][j][t % 2] |= dp[i][j - 1][!(t % 2)];
                }

                if (s[t - 1] == 'W' || s[t - 1] == '?'){
                    if (j != m - 1){
                        dp[i][j][t % 2] |= dp[i][j + 1][!(t % 2)];
                    }
                }
            }
        }
        
        
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            ans += dp[i][j][k & 1];
        }
    }
    cout << ans << '\n';
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 14036 KB Output is correct
2 Correct 22 ms 14036 KB Output is correct
3 Correct 23 ms 14164 KB Output is correct
4 Correct 20 ms 14144 KB Output is correct
5 Correct 16 ms 14164 KB Output is correct
6 Correct 12 ms 14112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 14036 KB Output is correct
2 Correct 22 ms 14036 KB Output is correct
3 Correct 23 ms 14164 KB Output is correct
4 Correct 20 ms 14144 KB Output is correct
5 Correct 16 ms 14164 KB Output is correct
6 Correct 12 ms 14112 KB Output is correct
7 Correct 26 ms 14164 KB Output is correct
8 Correct 24 ms 14036 KB Output is correct
9 Correct 21 ms 14036 KB Output is correct
10 Correct 17 ms 14120 KB Output is correct
11 Correct 16 ms 14024 KB Output is correct
12 Correct 30 ms 14112 KB Output is correct
13 Correct 28 ms 14144 KB Output is correct
14 Correct 31 ms 14036 KB Output is correct
15 Correct 18 ms 14112 KB Output is correct
16 Correct 12 ms 14164 KB Output is correct
17 Correct 33 ms 14164 KB Output is correct
18 Correct 30 ms 14164 KB Output is correct
19 Correct 23 ms 14160 KB Output is correct
20 Correct 18 ms 14036 KB Output is correct
21 Correct 12 ms 14036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 14036 KB Output is correct
2 Correct 22 ms 14036 KB Output is correct
3 Correct 23 ms 14164 KB Output is correct
4 Correct 20 ms 14144 KB Output is correct
5 Correct 16 ms 14164 KB Output is correct
6 Correct 12 ms 14112 KB Output is correct
7 Correct 26 ms 14164 KB Output is correct
8 Correct 24 ms 14036 KB Output is correct
9 Correct 21 ms 14036 KB Output is correct
10 Correct 17 ms 14120 KB Output is correct
11 Correct 16 ms 14024 KB Output is correct
12 Correct 30 ms 14112 KB Output is correct
13 Correct 28 ms 14144 KB Output is correct
14 Correct 31 ms 14036 KB Output is correct
15 Correct 18 ms 14112 KB Output is correct
16 Correct 12 ms 14164 KB Output is correct
17 Correct 33 ms 14164 KB Output is correct
18 Correct 30 ms 14164 KB Output is correct
19 Correct 23 ms 14160 KB Output is correct
20 Correct 18 ms 14036 KB Output is correct
21 Correct 12 ms 14036 KB Output is correct
22 Execution timed out 1081 ms 14292 KB Time limit exceeded
23 Halted 0 ms 0 KB -