Submission #1273747

#TimeUsernameProblemLanguageResultExecution timeMemory
1273747bhnmNautilus (BOI19_nautilus)C++20
100 / 100
167 ms157208 KiB
#include<bits/stdc++.h> using namespace std; bitset<505> dp[505][5005]; bitset<505> a[505]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m,l; cin >> n >> m >> l; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { char c; cin >> c; a[i] <<= 1; if(c=='.') { a[i]|=1; } } dp[i][0]=a[i]; } string s; cin >> s; s='.'+s; int ans=0; for(int j=1;j<=l;j++) { for(int i=1;i<=n;i++) { if(s[j]=='W') { dp[i][j]=(dp[i][j-1] << 1) & a[i]; } if(s[j]=='E') { dp[i][j]=(dp[i][j-1] >> 1) & a[i]; } if(s[j]=='N') { dp[i][j]=dp[i+1][j-1] & a[i]; } if(s[j]=='S') { dp[i][j]=dp[i-1][j-1] & a[i]; } if(s[j]=='?') { dp[i][j]=((dp[i][j-1] << 1) | (dp[i][j-1] >> 1) | dp[i-1][j-1] | dp[i+1][j-1]) & a[i]; } if(j==l) ans+=dp[i][j].count(); } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...