제출 #1350664

#제출 시각아이디문제언어결과실행 시간메모리
1350664stuckinpandemicNautilus (BOI19_nautilus)C++20
0 / 100
0 ms356 KiB
#include <bits/stdc++.h>
using namespace std;
#define tpl tuple<int32_t, int32_t, int32_t>
#define int long long
#define endl "\n"
#define pii pair<int, int>

void solve(){   
    int r, c, m; cin >> r >> c >> m;

    vector<bitset<500>> mask(r, bitset<500>(0)),
                        init(r, bitset<500>(0));

    vector<string> dir(r);
    for(int i = 0; i < r; i++) cin >> dir[i];

    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            mask[i][j] = (dir[i][j] == '.');
        }
        init[i] = mask[i];
    }

    string query; cin >> query;

    for(char ch: query){
        cout << ch << endl;
        vector<bitset<500>> temp(r, bitset<500>(0));
        if(ch == 'N' || ch == '?'){
            for(int i = 0; i < r - 1; i++){
                temp[i] |= mask[i + 1] & init[i];
            }
        }
        if(ch == 'S' || ch == '?'){
            for(int i = 1; i < r; i++){
                temp[i] |= mask[i - 1] & init[i];
            }
        }
        if(ch == 'E' || ch == '?'){
            for(int i = 0; i < r; i++){
                temp[i] |= (mask[i] << 1) & init[i];
            }
        }
        if(ch == 'W' || ch == '?'){
            for(int i = 0; i < r; i++){
                temp[i] |= (mask[i] >> 1) & init[i];
            }
        }
        mask = temp;
    }

    int cnt = 0;
    for(int i = 0; i < r; i++) cnt += mask[i].count();
    cout << cnt << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);   
    cin.tie(NULL);
    int test = 1;
    while(test--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...