#include <bits/stdc++.h>
// author: aykhn
using namespace std;
#define int long long
#define inf 0x3F3F3F3F
const int MXN = 20;
int n, m, K;
char mat[MXN][MXN];
string s;
bitset<MXN> dp[2][MXN], ok[MXN], x;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cin >> n >> m >> K;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> mat[i][j];
if (mat[i][j] != '#') ok[i].set(j, 1), dp[0][i].set(j, 1);
}
// for (int j = 0; j < m; j++) cout << dp[0][i][j];
// cout << '\n';
}
cin >> s;
s = "#" + s;
int ind = 1;
for (int k = 1; k <= K; k++)
{
for (int i = 0; i < n; i++)
{
dp[ind][i] = x;
if (i && (s[k] == 'S' || s[k] == '?')) dp[ind][i] |= dp[1 - ind][i - 1];
if (i + 1 < n && (s[k] == 'N' || s[k] == '?')) dp[ind][i] |= dp[1 - ind][i + 1];
if (s[k] == 'W' || s[k] == '?') dp[ind][i] |= dp[1 - ind][i] >> 1;
if (s[k] == 'E' || s[k] == '?') dp[ind][i] |= dp[1 - ind][i] << 1;
dp[ind][i] &= ok[i];
}
ind ^= 1;
}
int res = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
res += dp[K & 1][i][j];
}
}
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |