Submission #1105780

#TimeUsernameProblemLanguageResultExecution timeMemory
1105780vjudge1Kitchen (BOI19_kitchen)C++17
0 / 100
2 ms1104 KiB
#include <bits/stdc++.h> 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::vector<int>> can(r + 1, std::vector<int>(c + 1)); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { if (a[i][j] == '.') { can[i][j] = 1; } } } for (int it = 1; it <= m; it++) { std::vector<std::vector<int>> aux(r + 1, std::vector<int>(c + 1, 0)); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { if (a[i][j] == '#') { continue; } if (s[it] == '?') { for (int d = 0; d < 4; ++d) { int x = i + dx[d]; int y = j + dy[d]; if (1 <= x && x <= r && 1 <= y && y <= c && can[x][y] == 1) { aux[i][j] = 1; } } continue; } if (s[it] == 'W' && j + 1 <= c && can[i][j + 1] == 1) { aux[i][j] = 1; } if (s[it] == 'E' && j - 1 >= 1 && can[i][j - 1] == 1) { aux[i][j] = 1; } if (s[it] == 'N' && i + 1 <= r && can[i + 1][j] == 1) { aux[i][j] = 1; } if (s[it] == 'S' && i - 1 >= 1 && can[i - 1][j] == 1) { aux[i][j] = 1; } } } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...