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