Submission #281983

#TimeUsernameProblemLanguageResultExecution timeMemory
281983biggNautilus (BOI19_nautilus)C++14
100 / 100
55 ms896 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") const int MAXN = 510; bitset<MAXN> dp[MAXN][4], orig[MAXN]; int r, c, m; string s; int main(){ std::ios::sync_with_stdio(0); std::cin.tie(0); cin >> r >> c >> m; for(int i = 1; i <= r; i ++){ for(int j = 1; j <= c; j++){ char c; cin >> c; if(c == '.') dp[i][1][j] = 1, orig[i][j] = 1; } } cin >> s; for(int k = 0; k < m; k++ ){ int p = k%2; //printf("%d\n",p ); for(int i = 1; i <= r; i++){ dp[i][p].reset(); if(s[k] == '?')dp[i][p] = (dp[i-1][1-p] | dp[i+1][1-p] | dp[i][1-p]<<1 | dp[i][1-p] >> 1); if(s[k] == 'N') dp[i][p] = dp[i+1][1-p]; if(s[k] == 'S') dp[i][p] = dp[i-1][1-p]; if(s[k] == 'E') dp[i][p] = dp[i][1-p] << 1; if(s[k] == 'W') dp[i][p] = dp[i][1-p] >> 1; dp[i][p] &= orig[i]; //printf("%d ", dp[i][j][p]); //printf("\n"); } } int ans = 0; for(int i = 1; i <= r; i++){ //printf("%d",dp[i][j][1-m%2] ); ans += dp[i][1-m%2].count(); //printf("\n"); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...