Submission #1234524

#TimeUsernameProblemLanguageResultExecution timeMemory
1234524PlayVoltzNautilus (BOI19_nautilus)C++20
100 / 100
187 ms157876 KiB
#include <cstdio> #include <stdio.h> #include <stdbool.h> #include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> #include <cassert> #include <random> #include <chrono> #include <fstream> using namespace std; #define int long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k, ans=0; string s; cin>>n>>m>>k; char c; vector<vector<bitset<505> > > dp(k+1, vector<bitset<505> >(n+2, 0)); for (int i=1; i<=n; ++i)for (int j=1; j<=m; ++j){ cin>>c; if (c=='.')dp[0][i][j]=1; } cin>>s, s=" "+s; for (int i=1; i<=k; ++i){ if (s[i]=='N'||s[i]=='?')for (int j=1; j<=n; ++j)dp[i][j]|=dp[i-1][j+1]; if (s[i]=='S'||s[i]=='?')for (int j=1; j<=n; ++j)dp[i][j]|=dp[i-1][j-1]; if (s[i]=='W'||s[i]=='?')for (int j=1; j<=n; ++j)dp[i][j]|=(dp[i-1][j]>>1); if (s[i]=='E'||s[i]=='?')for (int j=1; j<=n; ++j)dp[i][j]|=(dp[i-1][j]<<1); for (int j=1; j<=n; ++j)dp[i][j]&=dp[0][j]; } for (auto a:dp[k])ans+=a.count(); cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...