제출 #1350949

#제출 시각아이디문제언어결과실행 시간메모리
1350949msab3fNautilus (BOI19_nautilus)C++20
100 / 100
88 ms556 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAX_R = 500 + 10;
const int MAX_C = 500 + 10;
const int MAX_M = 1000 + 10;

int r, c, m, ans;
string s;
bitset<MAX_C> curr[MAX_R], nxt[MAX_R], water[MAX_R];

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

    cin >> r >> c >> m;

    for (int i = 0; i < r; ++i) {
        string tmp;
        cin >> tmp;
        for (int j = 0; j < c; ++j) {
            curr[i][j] = water[i][j] = tmp[j] == '.';
        }
    }

    cin >> s;

    for (char mv : s) {
        if (mv == 'N' || mv == '?') {
            for (int i = 0; i + 1 < r; ++i) {
                nxt[i] |= curr[i + 1];
            }
        }
        if (mv == 'E' || mv == '?') {
            for (int i = 0; i < r; ++i) {
                nxt[i] |= curr[i] << 1;
            }
        }
        if (mv == 'S' || mv == '?') {
            for (int i = 1; i < r; ++i) {
                nxt[i] |= curr[i - 1];
            }
        }
        if (mv == 'W' || mv == '?') {
            for (int i = 0; i < r; ++i) {
                nxt[i] |= curr[i] >> 1;
            }
        }
        for (int i = 0; i < r; ++i) {
            curr[i] = nxt[i] & water[i];
            nxt[i].reset();
        }
    }

    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            if (curr[i][j]) {
                ++ans;
            }
        }
    }

    cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...