| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1283839 | red_souls | Nautilus (BOI19_nautilus) | C++20 | 203 ms | 157308 KiB | 
#include <bits/stdc++.h>
#define ll long long
#define task "nautilus"
using namespace std;
const int N = 516;
int n, m, q;
char a[N][N], d[5016];
namespace sub3 {
    bitset <502> sea[N], dp[502][5001];
    int result;
    void solve() {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (a[i][j] == '.') {
                    sea[i].set(j - 1);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            dp[i][0] = sea[i];
        }
        for (int t = 1; t <= q; t++) {
            for (int i = 1; i <= n; i++) {
                if (d[t] == 'N') {
                    dp[i][t] = dp[i + 1][t - 1] & sea[i];
                }
                if (d[t] == 'S') {
                    dp[i][t] = dp[i - 1][t - 1] & sea[i];
                }
                if (d[t] == 'E') {
                    dp[i][t] = (dp[i][t - 1] << 1) & sea[i];
                }
                if (d[t] == 'W') {
                    dp[i][t] = (dp[i][t - 1] >> 1) & sea[i];
                }
                if (d[t] == '?') {
                    dp[i][t] = (dp[i - 1][t - 1] | dp[i + 1][t - 1] | (dp[i][t - 1] << 1) | (dp[i][t - 1] >> 1)) & sea[i];
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                result += dp[i][q][j - 1];
            }
        }
        cout << result;
    }
}
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= q; i++) {
        cin >> d[i];
    }
    sub3 :: solve();
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
