답안 #314980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314980 2020-10-21T19:03:03 Z saarang123 Nautilus (BOI19_nautilus) C++14
100 / 100
149 ms 157304 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

const int N = 502;
const int M = 5002;
bitset<N> a[N];
bitset<N> dp[N][M];
signed main() {
    std::ios::sync_with_stdio(0);
    std::cout.tie(0);
    std::cin.tie(0);
    int n, m, k, i, j;
    cin >> n >> m >> k;
    for(i = 1; i <= n; i++) for(j = 1; j <= m; j++) {
        char c; cin >> c;
        if(c == '.') dp[i][0][j] = a[i][j] = true;
    }
    string s;
    cin >> s;
    for(int x = 0; x < k; x++) {
        if(s[x] == 'N') {
            for(i = 1; i < n; i++) dp[i][x + 1] |= (dp[i + 1][x] & a[i]);
        }
        else if(s[x] == 'S') {
            for(i = 2; i <= n; i++) dp[i][x + 1] |= (dp[i - 1][x] & a[i]);
        }
        else if(s[x] == 'E') {
            for(i = 1; i <= n; i++) dp[i][x + 1] |= ((dp[i][x] << 1) & a[i]);
        }
        else if(s[x] == 'W') {
            for(i = 1; i <= n; i++) dp[i][x + 1] |= ((dp[i][x] >> 1) & a[i]);
        }
        else {
            for(i = 1; i <= n; i++) dp[i][x + 1] |= (((dp[i][x] >> 1) | (dp[i][x] << 1) | dp[i + 1][x] | dp[i - 1][x]) & a[i]);
        }
    }
    int ans = 0;
    for(i = 1; i <= n; i++) for(j = 1; j <= m; j++) ans += dp[i][k][j];
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1440 KB Output is correct
2 Correct 1 ms 1408 KB Output is correct
3 Correct 1 ms 1408 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1440 KB Output is correct
2 Correct 1 ms 1408 KB Output is correct
3 Correct 1 ms 1408 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 1408 KB Output is correct
8 Correct 2 ms 1408 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 2 ms 1408 KB Output is correct
11 Correct 1 ms 1408 KB Output is correct
12 Correct 1 ms 1408 KB Output is correct
13 Correct 2 ms 1408 KB Output is correct
14 Correct 1 ms 1408 KB Output is correct
15 Correct 1 ms 1408 KB Output is correct
16 Correct 2 ms 1408 KB Output is correct
17 Correct 1 ms 1408 KB Output is correct
18 Correct 1 ms 1408 KB Output is correct
19 Correct 1 ms 1408 KB Output is correct
20 Correct 2 ms 1408 KB Output is correct
21 Correct 1 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1440 KB Output is correct
2 Correct 1 ms 1408 KB Output is correct
3 Correct 1 ms 1408 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 1408 KB Output is correct
8 Correct 2 ms 1408 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 2 ms 1408 KB Output is correct
11 Correct 1 ms 1408 KB Output is correct
12 Correct 1 ms 1408 KB Output is correct
13 Correct 2 ms 1408 KB Output is correct
14 Correct 1 ms 1408 KB Output is correct
15 Correct 1 ms 1408 KB Output is correct
16 Correct 2 ms 1408 KB Output is correct
17 Correct 1 ms 1408 KB Output is correct
18 Correct 1 ms 1408 KB Output is correct
19 Correct 1 ms 1408 KB Output is correct
20 Correct 2 ms 1408 KB Output is correct
21 Correct 1 ms 1408 KB Output is correct
22 Correct 140 ms 157176 KB Output is correct
23 Correct 145 ms 157176 KB Output is correct
24 Correct 141 ms 157048 KB Output is correct
25 Correct 138 ms 157140 KB Output is correct
26 Correct 139 ms 156924 KB Output is correct
27 Correct 140 ms 157188 KB Output is correct
28 Correct 139 ms 157304 KB Output is correct
29 Correct 141 ms 157304 KB Output is correct
30 Correct 149 ms 157176 KB Output is correct
31 Correct 139 ms 157032 KB Output is correct
32 Correct 140 ms 157304 KB Output is correct
33 Correct 145 ms 157304 KB Output is correct
34 Correct 142 ms 157304 KB Output is correct
35 Correct 146 ms 157188 KB Output is correct
36 Correct 138 ms 156920 KB Output is correct