Submission #1106075

#TimeUsernameProblemLanguageResultExecution timeMemory
1106075Andrei_ierdnANautilus (BOI19_nautilus)C++17
100 / 100
179 ms1016 KiB
#include <iostream> #include <bitset> using namespace std; const int MAXN = 500; int n, m, q; bitset<250505> valid, bs; char sir[5003]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> n >> m >> q; for (int i = 0; i < n; i++) { cin >> sir; for (int j = 0; j < m; j++) { if (sir[j] == '.') { valid.set(i*(m+1)+j); } } } cin >> sir; bs = valid; for (int i = 0; i < q; i++) { if (sir[i] == 'N') { bs >>= m+1; } else if (sir[i] == 'S') { bs <<= m+1; } else if (sir[i] == 'W') { bs >>= 1; } else if (sir[i] == 'E') { bs <<= 1; } else { bs = (bs >> (m+1)) | (bs << (m+1)) | (bs >> 1) | (bs << 1); } bs &= valid; } cout << bs.count(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...