이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 9;
const int M = 5e3 + 9;
bitset <N> dp[N][M], good[N];
int main () {
int r, c, m;
cin >> r >> c >> m;
for (int i = 1; i <= r; i++) {
for (int j = c; j >= 1; j--) {
char x;
cin >> x;
dp[i][0][j] = good[i][j] = (x == '.');
}
}
string s;
cin >> s;
s = "#" + s;
for (int t = 1; t <= m; t++) {
for (int i = 1; i <= r; i++) {
if (s[t] == 'N')
dp[i][t] = dp[i + 1][t - 1] & good[i];
if (s[t] == 'W')
dp[i][t] = (dp[i][t - 1] << 1) & good[i];
if (s[t] == '?')
dp[i][t] = (dp[i + 1][t - 1] | dp[i - 1][t - 1] | (dp[i][t - 1] << 1) | (dp[i][t - 1] >> 1)) & good[i];
if (s[t] == 'S')
dp[i][t] = dp[i - 1][t - 1] & good[i];
if (s[t] == 'E')
dp[i][t] = (dp[i][t - 1] >> 1) & good[i];
}
}
int res = 0;
for (int i = 1; i <= r; i++)
res += dp[i][m].count();
cout << res << "\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... |