Submission #531944

#TimeUsernameProblemLanguageResultExecution timeMemory
531944DeepessonNautilus (BOI19_nautilus)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define MAX 505 typedef std::bitset<MAX> bits; std::deque<bits> deq; int R,C,M; std::string comandos; bits mapa[MAX]; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); std::cin>>R>>C>>M; for(int i=0;i!=R;++i){ bits x={}; std::string s; std::cin >> s; for(int j=0;j!=C;++j){ if(s[j]!='#')x[j]=1; } mapa[i]=x; } for(int i=0;i!=R;++i){ bits x={}; for(int j=0;j!=C;++j){ x[j]=1; } x&=mapa[i]; deq.push_back(x); } std::cin>>comandos; for(int i=0;i!=M;++i){ char ch = comandos[i]; switch(ch){ ///esquerda case 'E':{ for(int i=0;i!=R;++i){ deq[i]=(deq[i]>>1)&mapa[i]; } }break; ///direita case 'W':{ for(int i=0;i!=R;++i){ deq[i]=(deq[i]<<1)&mapa[i]; } }break; ///norte: case 'N':{ for(int i=0;i!=R-1;++i){ deq[i]=(deq[i+1])&mapa[i]; } deq[R-1].set(0); }break; ///sul case 'S':{ for(int i=R-1;i!=0;--i){ deq[i]=(deq[i-1])&mapa[i]; } deq[0].set(0); }break; ///coringa case '?':{ std::deque<bits> nov; for(int i=0;i!=R;++i){ bits x={}; nov.push_back(x); } for(int i=0;i!=R;++i){ nov[i]|=(deq[i]>>1)&mapa[i]; } for(int i=0;i!=R;++i){ nov[i]|=(deq[i]<<1)&mapa[i]; } for(int i=0;i!=R-1;++i){ nov[i]|=(deq[i+1])&mapa[i]; } for(int i=1;i!=R;++i){ nov[i]|=(deq[i-1])&mapa[i]; } deq=nov; }break; } } int count=0; for(auto&x:deq)count+=x.count(); std::cout<<count<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...