This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 105;
char g[N][N];
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++) {
if (g[i][j] == '#')
continue;
int x = i, y = j;
bool ok = true;
for (int d = 0; d < k; d++) {
if (s[d] == 'N') x--;
if (s[d] == 'S') x++;
if (s[d] == 'W') y--;
if (s[d] == 'E') y++;
if (g[x][y] == '#') {
ok = false;
break;
}
}
ans += ok;
}
}
std::cout << ans << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |