Submission #1106738

#TimeUsernameProblemLanguageResultExecution timeMemory
1106738underwaterkillerwhaleNautilus (BOI19_nautilus)C++17
100 / 100
132 ms159056 KiB
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i=a;i<=b;i++) #define rep2(i,a,b,c) for (int i=a;i<=b;i+=c) #define rev(i,a,b) for (int i=a;i>=b;i--) #define rev2(i,a,b,c) for (int i=a;i>=b;i-=c) #define ii pair<ll,ll> #define bit(i,j) ((i>>j)&1) #define ull unsigned long long #define pb push_back #define pf push_front #define ll long long #define F first #define S second #define sz(a) (ll)(a.size()) #define on(n) __builtin_popcountll(n) #define ld long double #define __log2(x) 31-__builtin_clz(x) #define Mask(x) (1LL<<x) #define ALL(v) v.begin(),v.end() const int N=5e3+5; const int mod=1e9+7; const int INF=1e9; const int MAX=1e9; int n,m,k; string s; char a[505][505]; bitset<505> dp[N][505],mask[505]; void solution(){ cin >> n >> m >> k; rep(i,1,n) rep(j,1,m) cin >> a[i][j]; cin >> s; s=' '+s; rep(i,1,n) rep(j,1,m) if (a[i][j]=='.') dp[0][i].set(j),mask[i].set(j); rep(i,1,k) rep(row,1,n){ if (s[i]=='N'||s[i]=='?') dp[i][row]|=dp[i-1][row+1]; if (s[i]=='S'||s[i]=='?') dp[i][row]|=dp[i-1][row-1]; if (s[i]=='E'||s[i]=='?') dp[i][row]|=(dp[i-1][row]<<1); if (s[i]=='W'||s[i]=='?') dp[i][row]|=(dp[i-1][row]>>1); dp[i][row]&=mask[row]; } int res=0; rep(row,1,n) res+=dp[k][row].count(); cout << res; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int test=1; //cin >> test; while(test--) solution(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...