Submission #402940

#TimeUsernameProblemLanguageResultExecution timeMemory
402940rama_pangNautilus (BOI19_nautilus)C++17
100 / 100
189 ms660 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int R, C, M; cin >> R >> C >> M; vector<bitset<505>> A(R, 0); for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) { char c; cin >> c; if (c == '.') { A[i][j] = 1; } } } string S; cin >> S; vector<bitset<505>> dp = A; for (auto s : S) { vector<bitset<505>> ndp(R, 0); if (s == 'N' || s == '?') { for (int i = 0; i < R - 1; i++) { ndp[i] |= dp[i + 1]; } } if (s == 'S' || s == '?') { for (int i = 1; i < R; i++) { ndp[i] |= dp[i - 1]; } } if (s == 'E' || s == '?') { for (int i = 0; i <= R + 1; i++) { ndp[i] |= dp[i] << 1; } } if (s == 'W' || s == '?') { for (int i = 0; i < R; i++) { ndp[i] |= dp[i] >> 1; } } for (int i = 0; i < R; i++) { ndp[i] &= A[i]; } dp = ndp; } int ans = 0; for (int i = 0; i < R; i++) { ans += dp[i].count(); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...