Submission #125535

#TimeUsernameProblemLanguageResultExecution timeMemory
125535The_WolfpackNautilus (BOI19_nautilus)C++14
66 / 100
15 ms1656 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; memset(dp, false, sizeof(dp)); for(int i=0;i<r;i++) for(int j=0;j<c;j++) if(a[i][j]=='.') dp[0][i][j]=true; for(int t=1;t<=m;t++) { char sad=s[t-1]; for(int i=0;i<r;i++) { for(int j=0;j<c;j++) { if(a[i][j]=='#') continue; if((sad=='N' || sad=='?') && i+1<r) dp[t][i][j]=dp[t][i][j] || dp[t-1][i+1][j]; if((sad=='S' || sad=='?') && i-1>=0) dp[t][i][j]=dp[t][i][j] || dp[t-1][i-1][j]; if((sad=='W' || sad=='?') && j+1<c) dp[t][i][j]=dp[t][i][j] || dp[t-1][i][j+1]; if((sad=='E' || sad=='?') && j-1>=0) dp[t][i][j]=dp[t][i][j] || dp[t-1][i][j-1]; } } } int res=0; for(int i=0;i<r;i++) for(int j=0;j<c;j++) res+=(dp[m][i][j]>0); cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...