Submission #542685

#TimeUsernameProblemLanguageResultExecution timeMemory
542685StickfishNautilus (BOI19_nautilus)C++17
100 / 100
288 ms1100 KiB
#include <iostream> #include <bitset> using namespace std; const int MAXN = 501; const int SZ = MAXN * MAXN; bitset<SZ> empty_cell; bitset<SZ> move_west; bitset<SZ> move_east; bitset<SZ> move_south; bitset<SZ> ans; signed main() { int r, c, m; cin >> r >> c >> m; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { char ch; cin >> ch; empty_cell[i * c + j] = (ch == '.'); if (j) move_west[i * c + j] = empty_cell[i * c + j] & empty_cell[i * c + j - 1]; } } for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { if (j + 1 < c) move_east[i * c + j] = empty_cell[i * c + j] & empty_cell[i * c + j + 1]; if (i + 1 < r) move_south[i * c + j] = empty_cell[i * c + j] & empty_cell[i * c + j + c]; } } //cout << endl; ans = empty_cell; for (int i = 0; i < m; ++i) { char ch; cin >> ch; if (ch == 'N') { ans = (ans >> c) & empty_cell; } else if (ch == 'W') { ans = (ans & move_west) >> 1; } else if (ch == 'E') { ans = (ans & move_east) << 1; } else if (ch == 'S') { ans = (ans & move_south) << c; } else { ans = empty_cell & ((ans >> c) | ((ans & move_west) >> 1) | ((ans & move_east) << 1) | ((ans & move_south) << c)); } //cout << endl; //for (int l = 0; l < r; ++l) { //for (int j = 0; j < c; ++j) { //cout << ans[l * c + j]; //} //cout << endl; //} } cout << ans.count() << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...