답안 #921442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921442 2024-02-03T20:59:23 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
136 ms 1032 KB
#include <bits/stdc++.h>
 
// author: aykhn

using namespace std;

#define int long long
#define inf 0x3F3F3F3F

const int MXN = 5e2 + 5;

int n, m, K;
char mat[MXN][MXN];
string s;
bitset<MXN> dp[2][MXN], ok[MXN], x;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> K;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++) 
        {
            cin >> mat[i][j];
            if (mat[i][j] != '#') ok[i].set(j, 1), dp[0][i].set(j, 1);
        }
        // for (int j = 0; j < m; j++) cout << dp[0][i][j];
        // cout << '\n';
    }
    cin >> s;
    s = "#" + s;
    int ind = 1;
    for (int k = 1; k <= K; k++)
    {
        for (int i = 0; i < n; i++)
        {
            dp[ind][i] = x;
            if (i && (s[k] == 'S' || s[k] == '?')) dp[ind][i] |= dp[1 - ind][i - 1];
            if (i + 1 < n && (s[k] == 'N' || s[k] == '?')) dp[ind][i] |= dp[1 - ind][i + 1];
            if (s[k] == 'W' || s[k] == '?') dp[ind][i] |= dp[1 - ind][i] >> 1;
            if (s[k] == 'E' || s[k] == '?') dp[ind][i] |= dp[1 - ind][i] << 1;
            dp[ind][i] &= ok[i];
        }
        ind ^= 1;
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            res += dp[K & 1][i][j];
        }
    }
    cout << res << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 432 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 432 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 77 ms 604 KB Output is correct
23 Correct 66 ms 604 KB Output is correct
24 Correct 64 ms 856 KB Output is correct
25 Correct 79 ms 1032 KB Output is correct
26 Correct 63 ms 604 KB Output is correct
27 Correct 103 ms 792 KB Output is correct
28 Correct 106 ms 600 KB Output is correct
29 Correct 117 ms 792 KB Output is correct
30 Correct 105 ms 796 KB Output is correct
31 Correct 91 ms 776 KB Output is correct
32 Correct 122 ms 796 KB Output is correct
33 Correct 114 ms 804 KB Output is correct
34 Correct 114 ms 600 KB Output is correct
35 Correct 127 ms 792 KB Output is correct
36 Correct 136 ms 776 KB Output is correct