Submission #203361

#TimeUsernameProblemLanguageResultExecution timeMemory
203361mdn2002Nautilus (BOI19_nautilus)C++14
0 / 100
7 ms4600 KiB
#include<bits/stdc++.h> using namespace std; int n,m,k,xx[]={0,0,1,-1},yy[]={1,-1,0,0},a[105][105],dp[105][105][105]; char gr[105][105]; string s; void dfs(int x,int y,int in) { dp[x][y][in]=1; if(in==k) { a[x][y]=1; return; } if(dp[x][y][in])return; int tx=x,ty=y; if(s[in]=='E')ty++; else if(s[in]=='W')ty--; else if(s[in]=='N')tx--; else if(s[in]=='S')tx++; else { for(int i=0;i<4;i++) { tx=x+xx[i],ty=y+yy[i]; if(0<=tx&&tx<n&&0<=ty&&ty<m&&gr[tx][ty]=='.')dfs(tx,ty,in+1); } return; } if(0<=tx&&tx<n&&0<=ty&&ty<m&&gr[tx][ty]=='.')dfs(tx,ty,in+1); } int main() { cin>>n>>m>>k; for(int i=0;i<n;i++)cin>>gr[i]; cin>>s; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(gr[i][j]=='.')dfs(i,j,0); } } int ans=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(a[i][j])ans++; } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...