제출 #404044

#제출 시각아이디문제언어결과실행 시간메모리
404044fvogel499Nautilus (BOI19_nautilus)C++14
100 / 100
233 ms632 KiB
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;

#define pii pair<int, int>
#define f first
#define s second

#define ll long long
#define rint int32_t

rint main() {
    cin.tie(0);
    // ios_base::sync_with_stdio(0);

    int height, width, seqLength;
    cin >> height >> width >> seqLength;

    bitset<500> grid [height];
    for (int i = 0; i < height; i++) grid[i] = bitset<500>(0);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            char l;
            cin >> l;
            if (l == '.') grid[i][j] = 1;
        }
    }

    bitset<500> prev [height];
    for (int i = 0; i < height; i++) prev[i] = grid[i];
    for (int _ = 0; _ < seqLength; _++) {
        bitset<500> cur [height];
        for (int i = 0; i < height; i++) cur[i] = bitset<500>(0);
        char l;
        cin >> l;
        if (l == '?') {
            for (int i = 0; i < height; i++) {
                cur[i] = (prev[i]<<1);
                cur[i] |= (prev[i]>>1);
                if (i > 0) cur[i] |= prev[i-1];
                if (i < height-1) cur[i] |= prev[i+1];
                cur[i] &= grid[i];
            }
        }
        else if (l == 'S') for (int i = 1; i < height; i++) cur[i] = prev[i-1]&grid[i];
        else if (l == 'N') for (int i = 0; i < height-1; i++) cur[i] = prev[i+1]&grid[i];
        else if (l == 'E') for (int i = 0; i < height; i++) cur[i] = (prev[i]<<1)&grid[i];
        else if (l == 'W') for (int i = 0; i < height; i++) cur[i] = (prev[i]>>1)&grid[i];
        for (int i = 0; i < height; i++) prev[i] = cur[i];
    }

    int pos = 0;
    for (int i = 0; i < height; i++) pos += prev[i].count();

    cout << pos;

    int d = 0;
    d++;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...