답안 #643701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643701 2022-09-22T19:23:22 Z ParsaS Nautilus (BOI19_nautilus) C++14
100 / 100
539 ms 158748 KB
// In the name of God
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
const int N = 500 + 5, MOD = 1e9 + 7;
bitset<N> grid[N], mtc[N][N * 10];

void solve() {
    int n, m, k; cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        for (int j = 0; j < m; j++)
            grid[i][j] = s[j] == '.';
    }
    string s; cin >> s;
    for (int i = 0; i < n; i++) {
        mtc[i][0] = grid[i];
    }
    bitset<N> null = 0;
    s = '.' + s;

    for (int i = 1; i <= k; i++) {
        for (int ip = 0; ip < n; ip++) {
            if (s[i] == 'S' || s[i] == '?') {
                mtc[ip][i] = mtc[ip][i] | ((ip ? mtc[ip - 1][i - 1] : null) & grid[ip]);
            }
            if (s[i] == 'N' || s[i] == '?') {
                mtc[ip][i] = mtc[ip][i] | (mtc[ip + 1][i - 1] & grid[ip]);
            }
            if (s[i] == 'E' || s[i] == '?')
                mtc[ip][i] = (grid[ip] & (mtc[ip][i - 1] << 1)) | mtc[ip][i];
            if (s[i] == 'W' || s[i] == '?')
                mtc[ip][i] = mtc[ip][i] | (grid[ip] & (mtc[ip][i - 1] >> 1));
        }

    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += mtc[i][k].count();
    }
    cout << ans << endl;
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 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 1 ms 1364 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 1 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 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 2 ms 1364 KB Output is correct
8 Correct 1 ms 1408 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 2 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 1364 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 1 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 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 2 ms 1364 KB Output is correct
8 Correct 1 ms 1408 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 2 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 1364 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 240 ms 158692 KB Output is correct
23 Correct 214 ms 158700 KB Output is correct
24 Correct 224 ms 158688 KB Output is correct
25 Correct 205 ms 158688 KB Output is correct
26 Correct 211 ms 158716 KB Output is correct
27 Correct 288 ms 158652 KB Output is correct
28 Correct 301 ms 158668 KB Output is correct
29 Correct 285 ms 158748 KB Output is correct
30 Correct 306 ms 158656 KB Output is correct
31 Correct 310 ms 158732 KB Output is correct
32 Correct 363 ms 158700 KB Output is correct
33 Correct 539 ms 158676 KB Output is correct
34 Correct 372 ms 158636 KB Output is correct
35 Correct 413 ms 158624 KB Output is correct
36 Correct 356 ms 158676 KB Output is correct