Submission #1135134

#TimeUsernameProblemLanguageResultExecution timeMemory
1135134I_FloPPed21Nautilus (BOI19_nautilus)C++20
66 / 100
89 ms105284 KiB
#include <iostream> #include <bitset> using namespace std; const int R=501,M=5001; bitset<R> acces[R]; bitset<R> dp[R][M]; int n,m,moves; int main() { cin>>n>>m>>moves; string indicatii; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { char c; cin>>c; if(c=='.') { acces[i][j]=1; dp[i][0][j]=1; } } } cin>>indicatii; for(int i=1; i<=moves; i++) { for(int k=1; k<=n; k++) { if(indicatii[i-1]=='E'||indicatii[i-1]=='?') { dp[k][i]|=(dp[k][i-1]<<1); dp[k][i]&=acces[k]; } if(indicatii[i-1]=='W'||indicatii[i-1]=='?') { dp[k][i]|=(dp[k][i-1]>>1); dp[k][i]&=acces[k]; } if(indicatii[i-1]=='N'||indicatii[i-1]=='?') { dp[k][i]|=(dp[k+1][i-1]); dp[k][i]&=acces[k]; } if(indicatii[i-1]=='S'||indicatii[i-1]=='?') { dp[k][i]|=(dp[k-1][i-1]); dp[k][i]&=acces[k]; } } } int ans=0; for(int i=1; i<=n; i++) ans+=dp[i][moves].count(); cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...