Submission #927549

#TimeUsernameProblemLanguageResultExecution timeMemory
927549Faisal_SaqibNautilus (BOI19_nautilus)C++17
0 / 100
1 ms1624 KiB
#include <iostream> #include <bitset> using namespace std; char g[501][501],dir; int n,m,M; bitset<505> row[501][5002]; bitset<505> down[501],up[501],lef[501],righ[501]; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin>>n>>m>>M; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>g[i][j]; row[i][0][j]=(g[i][j]=='.'); } } for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { up[i][j]=((i-1)>=0 and g[i-1][j]=='.'); down[i][j]=((i+1)<n and g[i+1][j]=='.'); righ[i][j]=((j+1)<m and g[i][j+1]=='.'); lef[i][j]=((j-1)>=0 and g[i][j-1]=='.'); } } for(int j=0;j<M;j++) { cin>>dir; bool p=0; if(dir=='?') p=1; if(dir=='N' or p) { for(int i=1;i<n;i++) row[i-1][j+1]|=(row[i][j]&up[i]); } if(dir=='E' or p) { for(int i=0;i<(n-1);i++) row[i][j+1]|=((row[i][j]<<1)&righ[i]); } if(dir=='S' or p) { for(int i=0;i<(n-1);i++) row[i+1][j+1]|=(row[i][j]&down[i]); } if(dir=='W' or p) { for(int i=0;i<(n-1);i++) row[i][j+1]|=((row[i][j]>>1)&lef[i]); } } int ans=0; for(int x=0;x<n;x++) { for(int y=0;y<m;y++) { ans+=row[x][M][y]; // if(row[x][M][y]) // cout<<"Can end at "<<x<<' '<<y<<endl; } } cout<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...