답안 #565234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565234 2022-05-20T14:02:57 Z hoanghq2004 Nautilus (BOI19_nautilus) C++14
100 / 100
299 ms 157496 KB
#include <bits/stdc++.h>

using namespace std;

int n, m, k;
bitset <510> dp[510][5010], a[510];
int res;

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            char c;
            cin >> c;
            a[i][j] = (c == '.');
        }
    }
    string s;
    cin >> s;
    for (int i = 1; i <= n; ++i) dp[i][0] = a[i];
    for (int t = 1; t <= k; ++t) {
        for (int i = 1; i <= n; ++i) {
            if (s[t - 1] == 'N') dp[i][t] = dp[i + 1][t - 1] & a[i];
            if (s[t - 1] == 'S') dp[i][t] = dp[i - 1][t - 1] & a[i];
            if (s[t - 1] == 'W') dp[i][t] = (dp[i][t - 1] >> 1) & a[i];
            if (s[t - 1] == 'E') dp[i][t] = (dp[i][t - 1] << 1) & a[i];
            if (s[t - 1] == '?')
                dp[i][t] = (dp[i + 1][t - 1] & a[i]) | (dp[i - 1][t - 1] & a[i]) | ((dp[i][t - 1] >> 1) & a[i]) | ((dp[i][t - 1] << 1) & a[i]);
        }
    }
    for (int i = 1; i <= n; ++i) res += dp[i][k].count();
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 2 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 2 ms 1368 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 2 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 2 ms 1368 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 2 ms 1376 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 3 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 2 ms 1364 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 2 ms 1364 KB Output is correct
17 Correct 2 ms 1364 KB Output is correct
18 Correct 2 ms 1368 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 2 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 2 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 2 ms 1368 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 2 ms 1376 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 3 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 2 ms 1364 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 2 ms 1364 KB Output is correct
17 Correct 2 ms 1364 KB Output is correct
18 Correct 2 ms 1368 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 2 ms 1364 KB Output is correct
22 Correct 159 ms 157496 KB Output is correct
23 Correct 160 ms 157460 KB Output is correct
24 Correct 199 ms 157460 KB Output is correct
25 Correct 167 ms 157424 KB Output is correct
26 Correct 163 ms 157388 KB Output is correct
27 Correct 230 ms 157392 KB Output is correct
28 Correct 238 ms 157452 KB Output is correct
29 Correct 261 ms 157432 KB Output is correct
30 Correct 281 ms 157456 KB Output is correct
31 Correct 235 ms 157388 KB Output is correct
32 Correct 283 ms 157432 KB Output is correct
33 Correct 279 ms 157488 KB Output is correct
34 Correct 299 ms 157364 KB Output is correct
35 Correct 274 ms 157480 KB Output is correct
36 Correct 293 ms 157484 KB Output is correct