답안 #921441

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921441 2024-02-03T20:59:04 Z aykhn Nautilus (BOI19_nautilus) C++17
100 / 100
128 ms 1064 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 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 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 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 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 360 KB Output is correct
11 Correct 1 ms 532 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 512 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 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 360 KB Output is correct
11 Correct 1 ms 532 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 512 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 68 ms 604 KB Output is correct
23 Correct 65 ms 856 KB Output is correct
24 Correct 80 ms 856 KB Output is correct
25 Correct 64 ms 860 KB Output is correct
26 Correct 78 ms 1028 KB Output is correct
27 Correct 91 ms 1044 KB Output is correct
28 Correct 96 ms 1048 KB Output is correct
29 Correct 101 ms 1048 KB Output is correct
30 Correct 98 ms 1044 KB Output is correct
31 Correct 91 ms 1024 KB Output is correct
32 Correct 113 ms 856 KB Output is correct
33 Correct 113 ms 856 KB Output is correct
34 Correct 128 ms 1040 KB Output is correct
35 Correct 123 ms 1064 KB Output is correct
36 Correct 125 ms 1024 KB Output is correct