Submission #958192

#TimeUsernameProblemLanguageResultExecution timeMemory
958192ezzzayNautilus (BOI19_nautilus)C++14
100 / 100
181 ms1240 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define int long long #define ss second #define pb push_back const int N=5e3+5; const int NM=501; char arr[NM][NM]; bitset<NM> dp[NM]; bitset<NM>rck[NM]; bitset<NM>fll[NM]; signed main(){ int n,m,k; cin>>n>>m>>k; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>arr[i][j]; } } string s; cin>>s; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(arr[i][j]=='#'){ rck[i][j]=0; continue; } rck[i][j]=1; dp[i][j]=1; } } for(int l=0;l<k;l++){ bitset<NM>tmp[NM]; for(int i=1;i<=n;i++){ tmp[i]&=fll[i]; tmp[i]|=dp[i]; dp[i]&=fll[i]; } if(s[l]=='E'){ for(int i=1;i<=n;i++){ dp[i]|=(tmp[i]<<1); dp[i]&=rck[i]; } } else if(s[l]=='W'){ for(int i=1;i<=n;i++){ dp[i]|=(tmp[i]>>1); dp[i]&=rck[i]; } } else if(s[l]=='N'){ for(int i=1;i<=m;i++){ dp[i-1]|=tmp[i]; dp[i-1]&=rck[i-1]; } } else if(s[l]=='S'){ for(int i=1;i<=m;i++){ dp[i+1]|=tmp[i]; dp[i+1]&=rck[i+1]; } } else{ for(int i=1;i<=n;i++){ dp[i]|=(tmp[i]<<1); dp[i]&=rck[i]; } for(int i=1;i<=n;i++){ dp[i]|=(tmp[i]>>1); dp[i]&=rck[i]; } for(int i=1;i<=m;i++){ dp[i-1]|=tmp[i]; dp[i-1]&=rck[i-1]; } for(int i=1;i<=m;i++){ dp[i+1]|=tmp[i]; dp[i+1]&=rck[i+1]; } } } int cnt=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cnt+= dp[i][j]; } } cout<<cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...