제출 #1022014

#제출 시각아이디문제언어결과실행 시간메모리
1022014m5588ohammedNautilus (BOI19_nautilus)C++14
66 / 100
1067 ms83476 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" int n,m,p,cnt; char arr[501][501]; bool vis[501][501],dp[501][501][501]; string s; void solve(int i,int j,int k){ if(i>=n||j>=m||i<0||j<0||arr[i][j]=='#'||dp[i][j][k]==1||k>=500) return; if(k==p){ if(vis[i][j]!=1) cnt++; vis[i][j]=1; return; } dp[i][j][k]=1; if(s[k]=='N'||s[k]=='?') solve(i-1,j,k+1); if(s[k]=='S'||s[k]=='?') solve(i+1,j,k+1); if(s[k]=='E'||s[k]=='?') solve(i,j+1,k+1); if(s[k]=='W'||s[k]=='?') solve(i,j-1,k+1); return; } signed main() { cin>>n>>m>>p; for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cin>>arr[i][j]; } cin>>s; for(int i=0;i<n;i++){ for(int j=0;j<m;j++) solve(i,j,0); } cout<<cnt<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...