Submission #698464

#TimeUsernameProblemLanguageResultExecution timeMemory
698464karriganNautilus (BOI19_nautilus)C++14
100 / 100
212 ms684 KiB
#include<bits/stdc++.h> using namespace std; bitset<501>dp[2][509]; bitset<501>a[509]; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //freopen("usaco.INP","r",stdin); //freopen("usaco.OUT","w",stdout); int n,m,k; cin>>n>>m>>k; for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++){ char r; cin>>r; if (r=='.')dp[0][i][j]=a[i][j]=1; } } string s; cin>>s; s=" "+s; for (int i=1;i<=k;i++){ if (s[i]=='?'){ for (int j=1;j<=n;j++){ dp[1][j]=((dp[0][j-1])|(dp[0][j+1])|(dp[0][j]>>1)|(dp[0][j]<<1)); } } else if (s[i]=='N'){//up for (int j=1;j<=n;j++){ dp[1][j]|=(dp[0][j+1]); } } else if (s[i]=='E'){//right for (int j=1;j<=n;j++){ dp[1][j]|=(dp[0][j]<<1); } } else if (s[i]=='S'){//down for (int j=1;j<=n;j++){ dp[1][j]|=(dp[0][j-1]); } } else if (s[i]=='W'){//left for (int j=1;j<=n;j++){ dp[1][j]|=(dp[0][j]>>1); } } for (int j=1;j<=n;j++){ dp[1][j]&=a[j]; dp[0][j]=dp[1][j]; dp[1][j].reset(); } } int ans=0; for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++){ if (dp[0][i][j]){ ans++; } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...