Submission #1125080

#TimeUsernameProblemLanguageResultExecution timeMemory
1125080PanndaNautilus (BOI19_nautilus)C++20
100 / 100
130 ms560 KiB
#include <bits/stdc++.h> using namespace std; const int N = 501; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; vector<bitset<N>> mask(n); for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < m; j++) { if (s[j] == '.') mask[i].set(j); } } string s; cin >> s; vector<bitset<N>> prev = mask; vector<bitset<N>> dp(n); bitset<N> none; for (char ch : s) { if (ch == 'W') { for (int i = 0; i < n; i++) { dp[i] = (prev[i] >> 1) & mask[i]; } } if (ch == 'E') { for (int i = 0; i < n; i++) { dp[i] = (prev[i] << 1) & mask[i]; } } if (ch == 'N') { for (int i = 0; i + 1 < n; i++) { dp[i] = prev[i + 1] & mask[i]; } dp[n - 1].reset(); } if (ch == 'S') { dp[0].reset(); for (int i = 1; i < n; i++) { dp[i] = prev[i - 1] & mask[i]; } } if (ch == '?') { for (int i = 0; i < n; i++) { dp[i] = ( (prev[i] >> 1) | (prev[i] << 1) | (i == 0 ? none : prev[i - 1]) | (i == n - 1 ? none : prev[i + 1]) ) & mask[i]; } } prev = dp; } int ans = 0; for (int i = 0; i < n; i++) { ans += prev[i].count(); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...