Submission #868629

#TimeUsernameProblemLanguageResultExecution timeMemory
868629NeroZeinNautilus (BOI19_nautilus)C++17
100 / 100
112 ms1104 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 501; char c[N][N]; bitset<N> dp[N], ndp[N], ok[N]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> c[i][j]; ok[i][j] = (c[i][j] == '.'); } } string s; cin >> s; for (int i = 1; i <= n; ++i) { dp[i] = ok[i]; } for (int p = 0; p < k; ++p) { for (int i = 1; i <= n; ++i) { if (s[p] == 'W') { ndp[i] |= dp[i] >> 1; } else if (s[p] == 'E') { ndp[i] |= dp[i] << 1; } else if (s[p] == 'N') { ndp[i - 1] |= dp[i]; } else if (s[p] == 'S') { ndp[i + 1] |= dp[i]; } else { ndp[i] |= (dp[i] >> 1) | (dp[i] << 1); ndp[i - 1] |= dp[i]; ndp[i + 1] |= dp[i]; } } for (int i = 1; i <= n; ++i) { ndp[i] &= ok[i]; dp[i] = ndp[i]; ndp[i].reset(); } } int ans = 0; for (int i = 1; i <= n; ++i) { ans += dp[i].count(); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...