Submission #790561

#TimeUsernameProblemLanguageResultExecution timeMemory
790561tch1cherinNautilus (BOI19_nautilus)C++17
100 / 100
187 ms1108 KiB
#include <bits/stdc++.h> using namespace std; const int N = 505; bitset<N * N> bs, allowed, west, east; int main() { int r, c, m; cin >> r >> c >> m; auto Get = [&](int i, int j) { return i * c + j; }; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { char v; cin >> v; if (v == '.') { bs[Get(i, j)] = allowed[Get(i, j)] = true; } } } west.set(); east.set(); for (int i = 0; i < r; i++) { west[Get(i, 0)] = east[Get(i, c - 1)] = false; } string s; cin >> s; for (auto d : s) { if (d == '?') { bs = (((bs & east) << 1) | ((bs & west) >> 1) | (bs << c) | (bs >> c)) & allowed; } else if (d == 'N') { bs = (bs >> c) & allowed; } else if (d == 'S') { bs = (bs << c) & allowed; } else if (d == 'W') { bs = ((bs & west) >> 1) & allowed; } else { bs = ((bs & east) << 1) & allowed; } } cout << bs.count() << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...