Submission #1288603

#TimeUsernameProblemLanguageResultExecution timeMemory
1288603Hamed_GhaffariNautilus (BOI19_nautilus)C++20
100 / 100
156 ms724 KiB
#include <bits/stdc++.h> using namespace std; int r, c, m; bitset<500> bs[2][500], fr[500]; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> r >> c >> m; for(int i=0; i<r; i++) { for(int j=0; j<c; j++) { char x; cin >> x; bs[0][i][j] = fr[i][j] = x=='.'; } } string s; cin >> s; int t=0; for(char x : s) { for(int i=0; i<r; i++) bs[t^1][i] = 0; if(x=='N' || x=='?') { for(int i=1; i<r; i++) bs[t^1][i-1] |= bs[t][i]; } if(x=='E' || x=='?') { for(int i=0; i<r; i++) bs[t^1][i] |= bs[t][i]<<1; } if(x=='S' || x=='?') { for(int i=0; i+1<r; i++) bs[t^1][i+1] |= bs[t][i]; } if(x=='W' || x=='?') { for(int i=0; i<r; i++) bs[t^1][i] |= bs[t][i]>>1; } for(int i=0; i<r; i++) bs[t^1][i] &= fr[i]; t ^= 1; } int ans = 0; for(int i=0; i<r; i++) for(int j=0; j<c; j++) ans += bs[t][i][j]; cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...