이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int R, C, M;
cin >> R >> C >> M;
vector<bitset<505>> A(R, 0);
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
char c;
cin >> c;
if (c == '.') {
A[i][j] = 1;
}
}
}
string S;
cin >> S;
vector<bitset<505>> dp = A;
for (auto s : S) {
vector<bitset<505>> ndp(R, 0);
if (s == 'N' || s == '?') {
for (int i = 0; i < R - 1; i++) {
ndp[i] |= dp[i + 1];
}
}
if (s == 'S' || s == '?') {
for (int i = 1; i < R; i++) {
ndp[i] |= dp[i - 1];
}
}
if (s == 'E' || s == '?') {
for (int i = 0; i <= R + 1; i++) {
ndp[i] |= dp[i] << 1;
}
}
if (s == 'W' || s == '?') {
for (int i = 0; i < R; i++) {
ndp[i] |= dp[i] >> 1;
}
}
for (int i = 0; i < R; i++) {
ndp[i] &= A[i];
}
dp = ndp;
}
int ans = 0;
for (int i = 0; i < R; i++) {
ans += dp[i].count();
}
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... |