Submission #1105782

#TimeUsernameProblemLanguageResultExecution timeMemory
1105782vjudge1Nautilus (BOI19_nautilus)C++17
100 / 100
134 ms1208 KiB
#include <bits/stdc++.h> const int N = 505; int dx[] = {0, 0, -1, 1}; int dy[] = {-1, 1, 0, 0}; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int r, c, m; std::string s; std::cin >> r >> c >> m; std::vector<std::vector<char>> a(r + 1, std::vector<char>(c + 1)); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { std::cin >> a[i][j]; } } std::cin >> s; s = "#" + s; std::vector<std::bitset<N>> can(r + 2), good(r + 2); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { if (a[i][j] == '.') { can[i][j] = 1; good[i][j] = 1; } } } for (int it = 1; it <= m; it++) { std::vector<std::bitset<N>> aux(r + 2); for (int i = 1; i <= r; ++i) { if (s[it] == '?') { aux[i] = can[i - 1] | can[i + 1]; aux[i] |= can[i] << 1; aux[i] |= can[i] >> 1; } if (s[it] == 'W') { aux[i] = can[i] >> 1; } if (s[it] == 'E') { aux[i] = can[i] << 1; } if (s[it] == 'N') { aux[i] = can[i + 1]; } if (s[it] == 'S') { aux[i] = can[i - 1]; } aux[i] &= good[i]; } swap(can, aux); } int res = 0; for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { if (can[i][j] == 1) { res++; } } } std::cout << res << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...