제출 #1083103

#제출 시각아이디문제언어결과실행 시간메모리
1083103f0rizenNautilus (BOI19_nautilus)C++17
100 / 100
133 ms1068 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 1e9 + 7; const ll infll = 1e18; template<typename T> istream &operator>>(istream &is, vector<T> &a) { for (auto &i : a) { is >> i; } return is; } int32_t main() { #ifdef LOCAL freopen("/tmp/input.txt", "r", stdin); #else ios::sync_with_stdio(false); cin.tie(nullptr); #endif int n, m, k; cin >> n >> m >> k; vector<string> a(n); cin >> a; string s; cin >> s; vector<bitset<500>> sea(n); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (a[i][j] != '#') { sea[i][j] = 1; } } } vector<bitset<500>> dp = sea; for (int t = 0; t < k; ++t) { vector<bitset<500>> dpp(n); if (s[t] == 'N') { for (int i = 0; i + 1 < n; ++i) { dpp[i] |= (dp[i + 1] & sea[i]); } } else if (s[t] == 'E') { for (int i = 0; i < n; ++i) { dpp[i] |= ((dp[i] << 1) & sea[i]); } } else if (s[t] == 'S') { for (int i = 1; i < n; ++i) { dpp[i] |= (dp[i - 1] & sea[i]); } } else if (s[t] == 'W') { for (int i = 0; i < n; ++i) { dpp[i] |= ((dp[i] >> 1) & sea[i]); } } else { for (int i = 0; i + 1 < n; ++i) { dpp[i] |= (dp[i + 1] & sea[i]); } for (int i = 0; i < n; ++i) { dpp[i] |= ((dp[i] << 1) & sea[i]); } for (int i = 1; i < n; ++i) { dpp[i] |= (dp[i - 1] & sea[i]); } for (int i = 0; i < n; ++i) { dpp[i] |= ((dp[i] >> 1) & sea[i]); } } dp = dpp; } int ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (dp[i][j]) { ++ans; } } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...