#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 105, K = 105;
char g[N][N];
int dp[N][N][K];
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m, k;
std::cin >> n >> m >> k;
memset(g, '#', sizeof g);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
std::cin >> g[i][j];
}
}
std::string s;
std::cin >> s;
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
dp[i][j][0] = (g[i][j] == '.');
}
}
for (int K = 1; K <= k; K++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (g[i][j] == '#')
continue;
int x = i, y = j;
if (s[K - 1] == 'N') x++;
else if (s[K - 1] == 'S') x--;
else if (s[K - 1] == 'W') y++;
else if (s[K - 1] == 'E') y--;
else {
x--;
dp[i][j][K] |= dp[i - 1][j][K - 1];
dp[i][j][K] |= dp[i][j - 1][K - 1];
dp[i][j][K] |= dp[i + 1][j][K - 1];
dp[i][j][K] |= dp[i][j + 1][K - 1];
}
dp[i][j][K] |= dp[x][y][K - 1];
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
ans += dp[i][j][k];
}
}
std::cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4556 KB |
Output is correct |
2 |
Correct |
10 ms |
4648 KB |
Output is correct |
3 |
Correct |
8 ms |
4648 KB |
Output is correct |
4 |
Correct |
8 ms |
4656 KB |
Output is correct |
5 |
Correct |
6 ms |
4556 KB |
Output is correct |
6 |
Correct |
4 ms |
4556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4556 KB |
Output is correct |
2 |
Correct |
10 ms |
4648 KB |
Output is correct |
3 |
Correct |
8 ms |
4648 KB |
Output is correct |
4 |
Correct |
8 ms |
4656 KB |
Output is correct |
5 |
Correct |
6 ms |
4556 KB |
Output is correct |
6 |
Correct |
4 ms |
4556 KB |
Output is correct |
7 |
Correct |
9 ms |
4556 KB |
Output is correct |
8 |
Correct |
10 ms |
4648 KB |
Output is correct |
9 |
Correct |
12 ms |
4556 KB |
Output is correct |
10 |
Correct |
7 ms |
4652 KB |
Output is correct |
11 |
Correct |
5 ms |
4556 KB |
Output is correct |
12 |
Correct |
8 ms |
4556 KB |
Output is correct |
13 |
Correct |
9 ms |
4556 KB |
Output is correct |
14 |
Correct |
9 ms |
4556 KB |
Output is correct |
15 |
Correct |
7 ms |
4556 KB |
Output is correct |
16 |
Correct |
4 ms |
4556 KB |
Output is correct |
17 |
Correct |
9 ms |
4556 KB |
Output is correct |
18 |
Correct |
9 ms |
4556 KB |
Output is correct |
19 |
Correct |
9 ms |
4644 KB |
Output is correct |
20 |
Correct |
7 ms |
4556 KB |
Output is correct |
21 |
Correct |
4 ms |
4556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4556 KB |
Output is correct |
2 |
Correct |
10 ms |
4648 KB |
Output is correct |
3 |
Correct |
8 ms |
4648 KB |
Output is correct |
4 |
Correct |
8 ms |
4656 KB |
Output is correct |
5 |
Correct |
6 ms |
4556 KB |
Output is correct |
6 |
Correct |
4 ms |
4556 KB |
Output is correct |
7 |
Correct |
9 ms |
4556 KB |
Output is correct |
8 |
Correct |
10 ms |
4648 KB |
Output is correct |
9 |
Correct |
12 ms |
4556 KB |
Output is correct |
10 |
Correct |
7 ms |
4652 KB |
Output is correct |
11 |
Correct |
5 ms |
4556 KB |
Output is correct |
12 |
Correct |
8 ms |
4556 KB |
Output is correct |
13 |
Correct |
9 ms |
4556 KB |
Output is correct |
14 |
Correct |
9 ms |
4556 KB |
Output is correct |
15 |
Correct |
7 ms |
4556 KB |
Output is correct |
16 |
Correct |
4 ms |
4556 KB |
Output is correct |
17 |
Correct |
9 ms |
4556 KB |
Output is correct |
18 |
Correct |
9 ms |
4556 KB |
Output is correct |
19 |
Correct |
9 ms |
4644 KB |
Output is correct |
20 |
Correct |
7 ms |
4556 KB |
Output is correct |
21 |
Correct |
4 ms |
4556 KB |
Output is correct |
22 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |