# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1105780 |
2024-10-27T18:16:55 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
2 ms |
1104 KB |
#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 time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |