Submission #725603

#TimeUsernameProblemLanguageResultExecution timeMemory
725603_martynasNautilus (BOI19_nautilus)C++14
100 / 100
334 ms1772 KiB
#include <bits/stdc++.h> using namespace std; const int MXN = 505; int r, c, m; string A[MXN], moves; bitset<MXN*MXN> water, poss, first_col, first_row, last_col, last_row; int main() { cin >> r >> c >> m; for(int i = 0; i < r; i++) { cin >> A[i]; for(int j = 0; j < c; j++) { if(A[i][j] == '.') water[i*c+j] = 1; } } for(int i = 0; i < r; i++) { first_col[i*c] = 1; last_col[i*c+c-1] = 1; } for(int i = 0; i < c; i++) { first_row[i] = 1; last_row[(r-1)*c+i] = 1; } poss = water; cin >> moves; for(int i = 0; i < m; i++) { switch(moves[i]) { case 'N': poss = ((poss & ~first_row) >> c) & water; break; case 'E': poss = ((poss & ~last_col) << 1) & water; break; case 'S': poss = ((poss & ~last_row) << c) & water; break; case 'W': poss = ((poss & ~first_col) >> 1) & water; break; case '?': poss = (((poss & ~first_row) >> c) | ((poss & ~last_col) << 1) | ((poss & ~last_row) << c) | ((poss & ~first_col) >> 1)) & water; break; default: assert(false); } } cout << poss.count() << "\n"; return 0; } /* 3 3 1 ... .#. ... E */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...