Submission #547407

#TimeUsernameProblemLanguageResultExecution timeMemory
547407JomnoiNautilus (BOI19_nautilus)C++17
100 / 100
272 ms924 KiB
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; const int MAX_N = 5e2 + 10; char S[MAX_N][MAX_N]; bitset <MAX_N> dp[MAX_N], tmp[MAX_N], original[MAX_N]; int main() { cin.tie(0)->sync_with_stdio(0); int R, C, M; cin >> R >> C >> M; for(int i = 1; i <= R; i++) { cin >> (S[i] + 1); } for(int i = 1; i <= R; i++) { for(int j = 1; j <= C; j++) { if(S[i][j] == '.') { original[i][j] = 1; } } } string d; cin >> d; for(int i = 1; i <= R; i++) { dp[i] = original[i]; } for(auto v : d) { for(int i = 1; i <= R; i++) { tmp[i] = 0; } if(v == 'N' or v == '?') { for(int i = 1; i < R; i++) { tmp[i] |= dp[i + 1]; } } if(v == 'E' or v == '?') { for(int i = 1; i <= R; i++) { tmp[i] |= (dp[i]<<1); } } if(v == 'S' or v == '?') { for(int i = 2; i <= R; i++) { tmp[i] |= dp[i - 1]; } } if(v == 'W' or v == '?') { for(int i = 1; i <= R; i++) { tmp[i] |= (dp[i]>>1); } } for(int i = 1; i <= R; i++) { dp[i] = (tmp[i] & original[i]); } } int ans = 0; for(int i = 1; i <= R; i++) { ans += dp[i].count(); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...