Submission #543506

#TimeUsernameProblemLanguageResultExecution timeMemory
543506OttoTheDinoNautilus (BOI19_nautilus)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main () { int n, m, k; cin >> n >> m>>k; bitset<9> b[n], sea[n]; for (int i = 0; i < n; ++i) { for (int j = m-1; j >= 0; --j) { char c; cin >> c; b[i][j] = sea[i][j] = (c=='.'); } } for (int i=0;i<k;++i){ char c; cin >> c; bitset<9> nb[n]; if (c=='N') { for (int j=0;j<n-1;++j){ nb[j] = b[j+1]; } } else if (c=='S') { for (int j=1;j<n;++j){ nb[j] = b[j-1]; } } else if (c=='W') { for (int j=0;j<n;++j){ nb[j] = b[j]<<1; } } else if (c=='E') { for (int j=0;j<n;++j){ nb[j] = b[j]>>1; } } else { for (int j=0;j<n;++j){ if (j) nb[j] |= b[j-1]; if (j<n-1) nb[j] |= b[j+1]; nb[j] |= ((b[j]<<1)|(b[j]>>1)); } } for (int j=0;j<n;++j){ nb[j] &= sea[j]; } memcpy(b,nb,sizeof(nb)); } int ans=0; for (int i = 0; i<n; ++i){ ans += b[i].count(); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...