Submission #584743

#TimeUsernameProblemLanguageResultExecution timeMemory
584743penguinhackerNautilus (BOI19_nautilus)C++17
100 / 100
157 ms672 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=500; int n, m, q; bitset<mxN> mask[mxN], dp[mxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> q; for (int i=0; i<n; ++i) { string s; cin >> s; for (int j=0; j<m; ++j) if (s[j]=='.') mask[i][j]=1, dp[i][j]=1; } string query; cin >> query; for (char c : query) { bitset<mxN> ndp[mxN]; if (c=='W'||c=='?') for (int i=0; i<n; ++i) ndp[i]|=(dp[i]>>1)&mask[i]; if (c=='E'||c=='?') for (int i=0; i<n; ++i) ndp[i]|=(dp[i]<<1)&mask[i]; if (c=='N'||c=='?') for (int i=1; i<n; ++i) ndp[i-1]|=dp[i]&mask[i-1]; if (c=='S'||c=='?') for (int i=0; i+1<n; ++i) ndp[i+1]|=dp[i]&mask[i+1]; for (int i=0; i<n; ++i) swap(dp[i], ndp[i]); } int ans=0; for (int i=0; i<n; ++i) ans+=dp[i].count(); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...