제출 #450024

#제출 시각아이디문제언어결과실행 시간메모리
450024zxcvbnmNautilus (BOI19_nautilus)C++14
100 / 100
356 ms157704 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; bitset<505> dp[505][5005], sea[505]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; char mat[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; } } string str; cin >> str; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { sea[i][j] = mat[i][j] == '.'; } } for(int i = 0; i < n; i++) { dp[i][0] = sea[i]; } for(int t = 0; t < k; t++) { if (str[t] == 'N') { for(int i = 0; i < n; i++) { dp[i][t+1] = dp[i+1][t] & sea[i]; } } else if (str[t] == 'S') { for(int i = 1; i < n; i++) { dp[i][t+1] = dp[i-1][t] & sea[i]; } } else if (str[t] == 'E') { for(int i = 0; i < n; i++) { dp[i][t+1] = (dp[i][t] << 1) & sea[i]; } } else if (str[t] == 'W') { for(int i = 0; i < n; i++) { dp[i][t+1] = (dp[i][t] >> 1) & sea[i]; } } else if (str[t] == '?') { for(int i = 0; i < n; i++) { dp[i][t+1] = ((i+1 < n ? dp[i+1][t] : 0) | (i-1 >= 0 ? dp[i-1][t] : 0) | (dp[i][t] >> 1) | (dp[i][t] << 1)) & sea[i]; } } } int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { ans += dp[i][k][j]; } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...