#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 501;
char c[N][N];
bitset<10> dp[N], ndp[N], ok[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> c[i][j];
ok[i][j] = (c[i][j] == '.');
}
//deb(ok[i]) cout << '\n';
}
cout << '\n';
string s;
cin >> s;
for (int i = 1; i <= n; ++i) {
dp[i] = ok[i];
}
for (int p = 0; p < k; ++p) {
for (int i = 1; i <= n; ++i) {
if (s[p] == 'W') {
deb(dp[i]) cout << '\n';
ndp[i] |= dp[i] >> 1;
} else if (s[p] == 'E') {
ndp[i] |= dp[i] << 1;
} else if (s[p] == 'N') {
ndp[i - 1] |= dp[i];
} else if (s[p] == 'S') {
ndp[i + 1] |= dp[i];
} else {
ndp[i] |= (dp[i] >> 1) | (dp[i] << 1);
ndp[i - 1] |= dp[i];
ndp[i + 1] |= dp[i];
}
}
for (int i = 1; i <= n; ++i) {
ndp[i] &= ok[i];
dp[i] = ndp[i];
ndp[i].reset();
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
ans += dp[i].count();
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |