이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |