# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
918456 | 2024-01-29T20:58:40 Z | AlphaMale06 | Nautilus (BOI19_nautilus) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define yes cout << "YES\n" #define no cout << "NO\n" #define F first #define S second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() const int N = 503; bitset<N> dp[N]; bitset<N> blocks[N]; bitset<N> ndp[N]; void solve(){ int n, m, k; cin >> n >> m >> k; for(int i=1; i<=n; i++){ for(int j=m; j>=1; j--){ char c; cin >> c; if(c=='.'){ blocks[i][j]=1; dp[i][j]=1; } } } string s; cin >> s; for(int j=0; j< k; j++){ if(s[j]=='?'){ for(int i=1; i<=n; i++){ ndp[i]=(dp[i]<<1)|(dp[i]>>1)|(dp[i-1])|(dp[i+1]); } } else{ for(int i=1; i<=n; i++){ if(s[j]=='W'){ ndp[i]=dp[i]<<1; } if(s[j]=='E'){ ndp[i]=dp[i]>>1; } if(s[j]=='S'){ ndp[i]=dp[i-1]; } if(s[j]=='N'){ ndp[i]=dp[i+1]; } } } for(int i=0; i<=n+1; i++){ ndp[i]&=blocks[i]; } for(int i=1; i<=n; i++){ dp[i]=ndp[i]; } } int ans=0; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ ans+=dp[i][j]; } } cout << ans << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); solve();