Submission #475898

#TimeUsernameProblemLanguageResultExecution timeMemory
475898fadi57Nautilus (BOI19_nautilus)C++14
100 / 100
188 ms968 KiB
#include<bits/stdc++.h> using namespace std; const int mx=505; typedef long long ll; int mod=998244353 ; const int MXm=22; #define F first #define S second const int inf=1e9+10; bitset<mx> dp[mx]; bitset<mx> dp2[mx];//the previous bitset<mx>row[mx]; char ss[mx][mx]; string s; void solve(){ int n,m,k; cin>>n>>m>>k; for(int i =0;i<n;i++){ for(int j=0;j<m;j++){ cin>>ss[i][j]; if(ss[i][j]=='.'){ dp[i][j]=1; row[i][j]=1; } } } cin>>s; for(int i=1;i<=k;i++){ for(int i=0;i<n;i++){ dp2[i]=dp[i]; dp[i]&=0; } if(s[i-1]=='N'||s[i-1]=='?'){ for(int j=0;j<n;j++){ dp[j]|=(dp2[j+1]&row[j]); } } if(s[i-1]=='S'||s[i-1]=='?'){ for(int j=1;j<n;j++){ dp[j]|=(dp2[j-1]&row[j]); } } if(s[i-1]=='E'||s[i-1]=='?'){ for(int j=0;j<n;j++){ dp[j]|=((dp2[j]<<1)&row[j]); } } if(s[i-1]=='W'||s[i-1]=='?'){ for(int j=0;j<n;j++){ dp[j]|=((dp2[j]>>1)&row[j]); } } } ll ans=0; for(int i =0;i<n;i++){ ans+=dp[i].count(); } cout<<ans; return; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t;t=1; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...