Submission #209243

#TimeUsernameProblemLanguageResultExecution timeMemory
209243bensonlzlNautilus (BOI19_nautilus)C++14
100 / 100
225 ms888 KiB
#include <bits/stdc++.h> using namespace std; bitset<505> bs[2][505]; bitset<505> grid[505]; string s; int R, C, L; char x; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> R >> C >> L; for (int i = 1; i <= R; ++i){ for (int j = 1; j <= C; ++j){ cin >> x; if (x == '.'){ bs[0][i][j] = 1; grid[i][j] = 1; } else grid[i][j] = bs[0][i][j] = 0; } } cin >> s; for (int a = 1; a <= L; ++a){ if (s[a-1] == 'W'){ for (int i = 1; i <= R; ++i){ bs[a&1][i] = (bs[(a-1)&1][i] >> 1) & (grid[i]); } } if (s[a-1] == 'E'){ for (int i = 1; i <= R; ++i){ bs[a&1][i] = (bs[(a-1)&1][i] << 1) & (grid[i]); } } if (s[a-1] == 'N'){ for (int i = 1; i <= R; ++i){ bs[a&1][i] = bs[(a-1)&1][i+1] & (grid[i]); } } if (s[a-1] == 'S'){ for (int i = 1; i <= R; ++i){ bs[a&1][i] = bs[(a-1)&1][i-1] & (grid[i]); } } if (s[a-1] == '?'){ for (int i = 1; i <= R; ++i){ bs[a&1][i] = (bs[(a-1)&1][i-1] | bs[(a-1)&1][i+1] | (bs[(a-1)&1][i] << 1) | (bs[(a-1)&1][i] >> 1)) & (grid[i]); } } } int sum = 0; for (int i = 1; i <= R; ++i){ for (int j = 1; j <= C; ++j){ if (!grid[i][j]) continue; sum += bs[L&1][i][j]; } } cout << sum << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...