제출 #1268173

#제출 시각아이디문제언어결과실행 시간메모리
1268173dhuyyyyNautilus (BOI19_nautilus)C++20
100 / 100
177 ms157164 KiB
#include <bits/stdc++.h> #define fi first #define se second #define int long long using namespace std; using ll = long long; using ii = pair<int,int>; using pii = pair<int,ii>; using aa = array<int,3>; const int N = 1e5+5; const int INF = 1e18; const int MOD = 1e9+7; int n, m, k, res = 0; char c; string s; bitset<505> dp[505][5005]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m >> k; for (int i = 1; i <= n; i++){ for (int j = 1; j <= m; j++){ cin >> c; dp[i][0] <<= 1; if (c == '.') dp[i][0] |= 1; } } cin >> s; s = ' ' + s; for (int j = 1; j <= k; j++){ for (int i = 1; i <= n; i++){ if (s[j] == 'E'){ //di sang phai dp[i][j] = (dp[i][j-1] >> 1) & dp[i][0]; } else if (s[j] == 'W'){ //di sang trai dp[i][j] = (dp[i][j-1] << 1) & dp[i][0]; } else if (s[j] == 'S'){ //di xuong dp[i][j] = dp[i-1][j-1] & dp[i][0]; } else if (s[j] == 'N'){ // di len dp[i][j] = dp[i+1][j-1] & dp[i][0]; } else if (s[j] == '?'){ dp[i][j] = ((dp[i][j-1] >> 1) | (dp[i][j-1] << 1) | dp[i-1][j-1] | dp[i+1][j-1]) & dp[i][0]; } } } for (int i = 1; i <= n; i++) res += dp[i][k].count(); cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...