제출 #1358182

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

bitset<505> a[505], now[505], pre[505];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            char x;
            cin >> x;
            a[i][j]=(x=='.');
        }
        pre[i]=a[i];
    }
    string op;
    cin >> op;
    for(auto e:op){
        for(int i=0; i<n; i++){
            if(e=='N')now[i]|=pre[i+1];
            if(e=='S')now[i]|=pre[i-1];
            if(e=='E')now[i]|=pre[i]<<1;
            if(e=='W')now[i]|=pre[i]>>1;
            if(e=='?'){
                now[i]|=pre[i+1];
                now[i]|=pre[i-1];
                now[i]|=pre[i]<<1;
                now[i]|=pre[i]>>1;
            }
        }
        for(int i=0; i<n; i++){
            pre[i]=now[i]&a[i];
            now[i].reset();
        }
    }
    int ans=0;
    for(int i=0; i<n; i++)ans+=pre[i].count();
    cout << ans;
    
    return 0;
}
/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??

22
*/
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…