Submission #948163

#TimeUsernameProblemLanguageResultExecution timeMemory
948163Darren0724Nautilus (BOI19_nautilus)C++17
100 / 100
146 ms856 KiB
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false); cin.tie(0); //#define int long long #define all(x) x.begin(), x.end() #define endl '\n' const int N=505; const int INF=1e9; int32_t main() { LCBorz; bitset<N> grid[N],dp[N],dp1[N]; int n,m,t;cin>>n>>m>>t; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ char c;cin>>c; grid[i][j]=dp[i][j]=(c=='.'); } } string s;cin>>s; for(char c:s){ for(int i=0;i<n;i++){ dp1[i].reset(); } if(c=='W'||c=='?'){ for(int i=0;i<n;i++)dp1[i]|=dp[i]>>1; } if(c=='E'||c=='?'){ for(int i=0;i<n;i++)dp1[i]|=dp[i]<<1; } if(c=='N'||c=='?'){ for(int i=0;i<n;i++)dp1[i]|=dp[i+1]; } if(c=='S'||c=='?'){ for(int i=1;i<n;i++)dp1[i]|=dp[i-1]; } for(int i=0;i<n;i++){ dp[i]=dp1[i]&grid[i]; } } int ans=0; for(int i=0;i<n;i++){ ans+=dp[i].count(); } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...