Submission #211522

#TimeUsernameProblemLanguageResultExecution timeMemory
211522NnandiNautilus (BOI19_nautilus)C++14
66 / 100
298 ms3084 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 105; bool dp[maxn][maxn][maxn]; bool tab[maxn][maxn]; int r, c, m; string dir; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>r>>c>>m; for(int i=1;i<=r;i++) { for(int j=1;j<=c;j++) { char z; cin>>z; tab[i][j] = (z != '#'); dp[i][j][m] = (z != '#'); } } cin>>dir; reverse(dir.begin(),dir.end()); int sol = 0; for(int k=m-1;k>=0;k--) { for(int i=1;i<=r;i++) { for(int j=1;j<=c;j++) { map<char,bool> most; most['S'] = dp[i-1][j][k+1]; most['N'] = dp[i+1][j][k+1]; most['W'] = dp[i][j+1][k+1]; most['E'] = dp[i][j-1][k+1]; most['?'] = most['N'] || most['S'] || most['E'] || most['W']; dp[i][j][k] = (most[dir[k]] && tab[i][j]); if(k == 0 && dp[i][j][k]) sol++; } } } cout<<sol<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...