Submission #919935

#TimeUsernameProblemLanguageResultExecution timeMemory
919935AlebnNautilus (BOI19_nautilus)C++14
100 / 100
174 ms157580 KiB
#include <iostream> #include <vector> #include <map> #include <bitset> #define N 500 using namespace std; int n, m, len; string s; bool check(int i, int j) { if(i > -1 && j > -1 && i < n && j < m) return true; return false; } int main() { cin >> n >> m >> len; vector<bitset<N>> a(n, bitset<N>()); for(int i = 0; i < n; i++) { cin >> s; for(int j = 0; j < m; j++) { if(s[j] == '.') a[i][j] = 1; } } cin >> s; //dp vector<vector<bitset<N>>> dp(len+1, vector<bitset<N>>(n, bitset<N>())); //base case for(int i = 0; i < n; i++) dp[0][i] = a[i]; //transition for(int k = 1; k <= len; k++) { for(int i = 0; i < n; i++) { if((s[k-1] == 'N' || s[k-1] == '?') && i < n-1) dp[k][i] |= dp[k-1][i+1]; if(s[k-1] == 'E' || s[k-1] == '?') { dp[k][i] |= (dp[k-1][i]<<1); } if((s[k-1] == 'S' || s[k-1] == '?') && i > 0) dp[k][i] |= dp[k-1][i-1]; if(s[k-1] == 'W' || s[k-1] == '?') dp[k][i] |= (dp[k-1][i]>>1); dp[k][i] &= a[i]; } } //final state int res = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) res += dp[len][i][j]; } cout << res << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...