Submission #552076

#TimeUsernameProblemLanguageResultExecution timeMemory
552076ollelNautilus (BOI19_nautilus)C++14
0 / 100
1 ms340 KiB
using namespace std; #include <bits/stdc++.h> #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; int rows, cols, m; string commands; const int maxrows = 501; vector<bitset<maxrows>> blocked(maxrows); vector<bitset<maxrows>> yes(maxrows), nyes(maxrows); int main() { cin >> rows >> cols >> m; blocked.resize(rows); rep(r,0,rows) blocked[r].reset(); rep(r,0,rows) { string s; cin >> s; rep(c,0,cols) { if (s[c] == '.') blocked[r].set(c); } } cin >> commands; rep(r,0,rows) yes[r].set(); rep(i,0,m) { rep(r,0,rows) nyes[r].reset(); if (commands[i] == 'W') { rep(r,0,rows) nyes[r] = (yes[r] >> 1) & blocked[r]; } if (commands[i] == 'E') { rep(r,0,rows) nyes[r] = (yes[r] << 1) & blocked[r]; } if (commands[i] == 'S') { rep(r,0,rows - 1) nyes[r] = yes[r + 1] & blocked[r]; } if (commands[i] == 'N') { rep(r,1,rows) nyes[r] = yes[r - 1] & blocked[r]; } if (commands[i] == '?') { nyes[0] = (yes[1] | (yes[0] >> 1) | (yes[0] << 1)) & blocked[0]; rep(r,1,rows - 1) { nyes[r] = (yes[r + 1] | yes[r - 1] | (yes[r] >> 1) | (yes[r] << 1)) & blocked[r]; } nyes[rows - 1] = (yes[rows - 2] | (yes[rows - 1] >> 1) | (yes[rows - 1] << 1)) & blocked[rows - 1]; } rep(r,0,rows) yes[r] = nyes[r]; } int ans = 0; rep(r,0,rows) rep(c,0,cols) if (yes[r].test(c)) ans++; cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...