Submission #125538

#TimeUsernameProblemLanguageResultExecution timeMemory
125538The_WolfpackNautilus (BOI19_nautilus)C++14
29 / 100
4 ms1020 KiB
#include <bits/stdc++.h> using namespace std; int r,c,m; char a[105][105]; string s; bool dp[105][105][105]; int main() { ios_base::sync_with_stdio(false); cin>>r>>c>>m; for(int i=0;i<r;i++) for(int j=0;j<c;j++) cin>>a[i][j]; cin>>s; bitset<500> dp[m+10][r]; bitset<500> red[r]; for(int i=0;i<r;i++) for(int j=0;j<c;j++) { if(a[i][j]=='#') { dp[0][i][j]=0; red[i][j]=0; } else { dp[0][i][j]=1; red[i][j]=1; } } for(int t=1;t<=m;t++) { char sad=s[t-1]; for(int i=0;i<r;i++) { if(sad=='W') dp[t][i]=(dp[t-1][i]>>1) & red[i]; if(sad=='E') dp[t][i]=(dp[t-1][i]<<1) & red[i]; if(sad=='S' && i) dp[t][i]=dp[t-1][i-1] & red[i]; if(sad=='N' && i+1<r) dp[t][i]=dp[t-1][i+1] & red[i]; /*else { }*/ } } int res=0; for(int i=0;i<r;i++) res+=dp[m][i].count(); cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...