답안 #314976

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314976 2020-10-21T18:57:27 Z saarang123 Nautilus (BOI19_nautilus) C++14
100 / 100
310 ms 157324 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

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 1408 KB Output is correct
2 Correct 1 ms 1408 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 1 ms 1408 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1408 KB Output is correct
2 Correct 1 ms 1408 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 1 ms 1408 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 2 ms 1408 KB Output is correct
9 Correct 2 ms 1408 KB Output is correct
10 Correct 2 ms 1408 KB Output is correct
11 Correct 2 ms 1408 KB Output is correct
12 Correct 2 ms 1408 KB Output is correct
13 Correct 2 ms 1408 KB Output is correct
14 Correct 2 ms 1408 KB Output is correct
15 Correct 2 ms 1408 KB Output is correct
16 Correct 2 ms 1408 KB Output is correct
17 Correct 2 ms 1408 KB Output is correct
18 Correct 2 ms 1408 KB Output is correct
19 Correct 2 ms 1408 KB Output is correct
20 Correct 2 ms 1408 KB Output is correct
21 Correct 2 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1408 KB Output is correct
2 Correct 1 ms 1408 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 1 ms 1408 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 2 ms 1408 KB Output is correct
9 Correct 2 ms 1408 KB Output is correct
10 Correct 2 ms 1408 KB Output is correct
11 Correct 2 ms 1408 KB Output is correct
12 Correct 2 ms 1408 KB Output is correct
13 Correct 2 ms 1408 KB Output is correct
14 Correct 2 ms 1408 KB Output is correct
15 Correct 2 ms 1408 KB Output is correct
16 Correct 2 ms 1408 KB Output is correct
17 Correct 2 ms 1408 KB Output is correct
18 Correct 2 ms 1408 KB Output is correct
19 Correct 2 ms 1408 KB Output is correct
20 Correct 2 ms 1408 KB Output is correct
21 Correct 2 ms 1408 KB Output is correct
22 Correct 227 ms 157304 KB Output is correct
23 Correct 193 ms 157304 KB Output is correct
24 Correct 195 ms 157304 KB Output is correct
25 Correct 195 ms 157324 KB Output is correct
26 Correct 192 ms 157304 KB Output is correct
27 Correct 254 ms 157308 KB Output is correct
28 Correct 253 ms 157304 KB Output is correct
29 Correct 257 ms 157304 KB Output is correct
30 Correct 253 ms 157304 KB Output is correct
31 Correct 253 ms 157176 KB Output is correct
32 Correct 299 ms 157304 KB Output is correct
33 Correct 305 ms 157304 KB Output is correct
34 Correct 302 ms 157304 KB Output is correct
35 Correct 310 ms 157304 KB Output is correct
36 Correct 300 ms 157180 KB Output is correct