Submission #947592

#TimeUsernameProblemLanguageResultExecution timeMemory
947592VMaksimoski008Nautilus (BOI19_nautilus)C++14
66 / 100
172 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int32_t main() { int n, m, K, ans = 0; cin >> n >> m >> K; char mat[n][m]; for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> mat[i][j]; string s; cin >> s; s = "." + s; bool dp[K+1][n][m]; memset(dp, 0, sizeof(dp)); for(int i=0; i<n; i++) for(int j=0; j<m; j++) dp[0][i][j] = (mat[i][j] == '.'); for(int i=1; i<=K; i++) { for(int r=0; r<n; r++) { for(int c=0; c<m; c++) { if(mat[r][c] == '#') continue; if((s[i] == 'W' || s[i] == '?') && c + 1 < m && dp[i-1][r][c+1]) dp[i][r][c] = 1; if((s[i] == 'E' || s[i] == '?') && c - 1 >= 0 && dp[i-1][r][c-1]) dp[i][r][c] = 1; if((s[i] == 'N' || s[i] == '?') && r + 1 < n && dp[i-1][r+1][c]) dp[i][r][c] = 1; if((s[i] == 'S' || s[i] == '?') && r - 1 >= 0 && dp[i-1][r-1][c]) dp[i][r][c] = 1; } } } for(int i=0; i<n; i++) for(int j=0; j<m; j++) ans += dp[K][i][j]; cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...