#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 505;
const ll inf = 2e9;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
vector < bitset <M> > dp(M);
bitset <M> a[M];
string s;
int n, m, ans, len;
int main()
{
cin >> n >> m >> len;
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j){
char c;
cin >> c;
if(c == '.') a[i][j] = 1, dp[i][j] = 1;
}
cin >> s;
for(int i = 0; i < len; ++i){
vector < bitset <M> > to(M);
for(int j = 1; j <= n; ++j){
if(s[i] == '?' || s[i] == 'N') to[j - 1] |= dp[j];
if(s[i] == '?' || s[i] == 'S') to[j + 1] |= dp[j];
if(s[i] == '?' || s[i] == 'E') to[j] |= (dp[j] << 1);
if(s[i] == '?' || s[i] == 'W') to[j] |= (dp[j] >> 1);
}
dp = to;
for(int j = 1; j <= n; ++j) dp[j] &= a[j];
}
for(int i = 1; i <= n; ++i) ans += dp[i].count();
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
89 ms |
588 KB |
Output is correct |
23 |
Correct |
92 ms |
628 KB |
Output is correct |
24 |
Correct |
95 ms |
576 KB |
Output is correct |
25 |
Correct |
89 ms |
580 KB |
Output is correct |
26 |
Correct |
98 ms |
612 KB |
Output is correct |
27 |
Correct |
117 ms |
580 KB |
Output is correct |
28 |
Correct |
123 ms |
588 KB |
Output is correct |
29 |
Correct |
122 ms |
568 KB |
Output is correct |
30 |
Correct |
133 ms |
628 KB |
Output is correct |
31 |
Correct |
123 ms |
588 KB |
Output is correct |
32 |
Correct |
151 ms |
584 KB |
Output is correct |
33 |
Correct |
146 ms |
632 KB |
Output is correct |
34 |
Correct |
145 ms |
580 KB |
Output is correct |
35 |
Correct |
144 ms |
564 KB |
Output is correct |
36 |
Correct |
146 ms |
564 KB |
Output is correct |