제출 #941815

#제출 시각아이디문제언어결과실행 시간메모리
941815phoenix0423Nautilus (BOI19_nautilus)C++17
100 / 100
97 ms848 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;

signed main(void){
    fastio;
    int r, c, m;
    cin>>r>>c>>m;
    vector<bitset<501>> st(r);
    for(int i = 0; i < r; i++){
        string s;
        cin>>s;
        for(int j = 0; j < c; j++){
            if(s[j] == '.') st[i][j] = 1;
        }
    }
    string op;
    cin>>op;
    vector<bitset<501>> cur(st);
    for(int i = 0; i < m; i++){
        vector<bitset<501>> nw(r);
        if(op[i] == 'E' || op[i] == '?'){
            for(int j = 0; j < r; j++){
                nw[j] |= (cur[j] << 1);
                nw[j] &= st[j];
            }
        }
        if(op[i] == 'W' || op[i] == '?'){
            for(int j = 0; j < r; j++){
                nw[j] |= (cur[j] >> 1);
                nw[j] &= st[j];
            }
        }
        if(op[i] == 'N' || op[i] == '?'){
            for(int j = r - 2; j >= 0; j--){
                nw[j] |= cur[j + 1];
                nw[j] &= st[j];
            }
        }
        if(op[i] == 'S' || op[i] == '?'){
            bitset<501> acc;
            for(int j = 1; j < r; j++){
                nw[j] |= cur[j - 1];
                nw[j] &= st[j];
            }
        }
        swap(cur, nw);
    }
    int ans = 0;
    for(int i = 0; i < r; i++) ans += cur[i].count();
    cout<<ans<<"\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...