Submission #412459

#TimeUsernameProblemLanguageResultExecution timeMemory
412459mbfibatNautilus (BOI19_nautilus)C++17
100 / 100
207 ms960 KiB
#pragma GCC target("popcnt") #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; int R, C, M; string s; char c[501][501]; bitset<250000> org, cur, E, W; int id(int i, int j) { return i * C + j; } int main(int argc, char** argv) { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> R >> C >> M; for (int i = 0; i < R; i++) for (int j = 0; j < C; j++) { cin >> c[i][j]; int pos = id(i, j); if (c[i][j] == '.') { org.set(pos); cur.set(pos); } if (j != C - 1) W.set(pos); if (j != 0) E.set(pos); } cin >> s; for (int i = 0; i < M; i++) { if (s[i] == 'N') cur = (cur >> C); else if (s[i] == 'S') cur = (cur << C); else if (s[i] == 'W') cur = (cur >> 1) & W; else if (s[i] == 'E') cur = (cur << 1) & E; else cur = ((cur >> C) | (cur << C) | ((cur >> 1) & W) | ((cur << 1) & E)); cur &= org; } cout << cur.count(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...