이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
using Val = bitset<N>;
Val org[N];
Val now[N];
Val nxt[N];
int main() {
ios_base::sync_with_stdio(false);
int n, m, k;
cin >> n >> m >> k;
vector<string> brd(n);
for (int i = 0; i < n; ++i) {
cin >> brd[i];
for (int j = 0; j < m; ++j) {
if (brd[i][j] == '.') {
org[i].set(j);
}
}
now[i] = org[i];
}
string mvs;
cin >> mvs;
for (char c : mvs) {
for (int i = 0; i < n; ++i) {
nxt[i] = {};
}
if (c == 'N' || c == '?') {
for (int i = 0; i + 1 < n; ++i) {
nxt[i] |= now[i + 1];
}
}
if (c == 'E' || c == '?') {
for (int i = 0; i < n; ++i) {
nxt[i] |= (now[i] << 1);
}
}
if (c == 'S' || c == '?') {
for (int i = 1; i < n; ++i) {
nxt[i] |= now[i - 1];
}
}
if (c == 'W' || c == '?') {
for (int i = 0; i < n; ++i) {
nxt[i] |= (now[i] >> 1);
}
}
for (int i = 0; i < n; ++i) {
now[i] = nxt[i] & org[i];
}
}
int ans = 0;
for (int i = 0; i < n; ++i) {
ans += now[i].count();
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |