제출 #1125605

#제출 시각아이디문제언어결과실행 시간메모리
1125605thinknoexitNautilus (BOI19_nautilus)C++20
100 / 100
122 ms536 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; bitset<505> a[505]; bitset<505> dp[2][505]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m, Q; cin >> n >> m >> Q; for (int i = 1;i <= n;i++) { for (int j = 1;j <= m;j++) { char t; cin >> t; a[i][j] = (t == '.'); } } for (int i = 1;i <= n;i++) dp[0][i] = a[i]; for (int st = 1;st <= Q;st++) { int now = st & 1, prev = 1 - now; // char c; cin >> c; if (c == 'N') { for (int i = 1;i < n;i++) { dp[now][i] = dp[prev][i + 1] & a[i]; } dp[now][n].reset(); } else if (c == 'S') { for (int i = 2;i <= n;i++) { dp[now][i] = dp[prev][i - 1] & a[i]; } dp[now][1].reset(); } else if (c == 'E') { for (int i = 1;i <= n;i++) { dp[now][i] = (dp[prev][i] << 1) & a[i]; } } else if (c == 'W') { for (int i = 1;i <= n;i++) { dp[now][i] = (dp[prev][i] >> 1) & a[i]; } } else { for (int i = 1;i <= n;i++) { dp[now][i].reset(); dp[now][i] |= dp[prev][i - 1]; dp[now][i] |= dp[prev][i + 1]; dp[now][i] |= dp[prev][i] >> 1; dp[now][i] |= dp[prev][i] << 1; dp[now][i] &= a[i]; } } } int ans = 0; for (int i = 1;i <= n;i++) { ans += dp[Q & 1][i].count(); } cout << ans << '\n'; return 0; } /* 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...