#include <bits/stdc++.h>
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define pii pair <int,int>
#define pll pair <ll,ll>
#define piii pair <int,pii>
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define forr(_a,_b,_c) for(int _a = _b; _a <= _c; ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> _c;)
#define forf(_a,_b,_c) for(int _a = _b; _a < _c; ++_a)
#define all(x) begin(x),end(x)
#define file "test"
using namespace std;
const int N=2e5 + 5;
const ll oo = 1e9;
bitset <502> bit[502],f[5002][502];
int r,c,M;
string a[505],m;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> r >> c >> M;
forf (i,0,r)
cin >> a[i];
cin >> m;
memset(f,0,sizeof f);
memset(bit,0,sizeof bit);
m = '*' + m;
forf (i,0,r)
forf (j,0,c)
if (a[i][j] == '.')
bit[i].set((c - j - 1),1);
forf (i,0,r)
f[0][i] = (bit[i]);
forr (i,1,M)
{
//cout << m[i] << endl;
forf (j,0,r)
{
if (m[i] == 'W')
f[i][j] = (f[i-1][j] << 1) & f[0][j];
if (m[i] == 'E')
f[i][j] = (f[i-1][j] >> 1) & f[0][j];
if (m[i] == 'N' && j < r - 1)
f[i][j] = f[i-1][j+1] & f[0][j];
if (m[i] == 'S' && j != 0)
f[i][j] = f[i-1][j - 1] & f[0][j];
if (m[i] == '?')
f[i][j] = ((f[i-1][j] << 1) | (f[i-1][j] >> 1) | f[i-1][j+1] | f[i-1][j - 1]) & f[0][j];
// cout << f[i][j] << endl;
}
// cout << endl;
}
int ans = 0;
forf (i,0,r)
ans += f[M][i].count();
cout << ans;
return 0;
}
/*
*/
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:31:28: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'class std::bitset<502>'; use assignment or value-initialization instead [-Wclass-memaccess]
31 | memset(bit,0,sizeof bit);
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66,
from nautilus.cpp:1:
/usr/include/c++/10/bitset:751:11: note: 'class std::bitset<502>' declared here
751 | class bitset
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
157508 KB |
Output is correct |
2 |
Correct |
59 ms |
157552 KB |
Output is correct |
3 |
Correct |
64 ms |
157516 KB |
Output is correct |
4 |
Correct |
72 ms |
157508 KB |
Output is correct |
5 |
Correct |
59 ms |
157576 KB |
Output is correct |
6 |
Correct |
63 ms |
157524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
157508 KB |
Output is correct |
2 |
Correct |
59 ms |
157552 KB |
Output is correct |
3 |
Correct |
64 ms |
157516 KB |
Output is correct |
4 |
Correct |
72 ms |
157508 KB |
Output is correct |
5 |
Correct |
59 ms |
157576 KB |
Output is correct |
6 |
Correct |
63 ms |
157524 KB |
Output is correct |
7 |
Correct |
60 ms |
157620 KB |
Output is correct |
8 |
Correct |
70 ms |
157616 KB |
Output is correct |
9 |
Correct |
61 ms |
157544 KB |
Output is correct |
10 |
Correct |
61 ms |
157532 KB |
Output is correct |
11 |
Correct |
66 ms |
157552 KB |
Output is correct |
12 |
Correct |
60 ms |
157780 KB |
Output is correct |
13 |
Correct |
59 ms |
157528 KB |
Output is correct |
14 |
Correct |
60 ms |
157516 KB |
Output is correct |
15 |
Correct |
70 ms |
157500 KB |
Output is correct |
16 |
Correct |
62 ms |
157584 KB |
Output is correct |
17 |
Correct |
59 ms |
157516 KB |
Output is correct |
18 |
Correct |
68 ms |
157612 KB |
Output is correct |
19 |
Correct |
59 ms |
157492 KB |
Output is correct |
20 |
Correct |
59 ms |
157520 KB |
Output is correct |
21 |
Correct |
61 ms |
157592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
157508 KB |
Output is correct |
2 |
Correct |
59 ms |
157552 KB |
Output is correct |
3 |
Correct |
64 ms |
157516 KB |
Output is correct |
4 |
Correct |
72 ms |
157508 KB |
Output is correct |
5 |
Correct |
59 ms |
157576 KB |
Output is correct |
6 |
Correct |
63 ms |
157524 KB |
Output is correct |
7 |
Correct |
60 ms |
157620 KB |
Output is correct |
8 |
Correct |
70 ms |
157616 KB |
Output is correct |
9 |
Correct |
61 ms |
157544 KB |
Output is correct |
10 |
Correct |
61 ms |
157532 KB |
Output is correct |
11 |
Correct |
66 ms |
157552 KB |
Output is correct |
12 |
Correct |
60 ms |
157780 KB |
Output is correct |
13 |
Correct |
59 ms |
157528 KB |
Output is correct |
14 |
Correct |
60 ms |
157516 KB |
Output is correct |
15 |
Correct |
70 ms |
157500 KB |
Output is correct |
16 |
Correct |
62 ms |
157584 KB |
Output is correct |
17 |
Correct |
59 ms |
157516 KB |
Output is correct |
18 |
Correct |
68 ms |
157612 KB |
Output is correct |
19 |
Correct |
59 ms |
157492 KB |
Output is correct |
20 |
Correct |
59 ms |
157520 KB |
Output is correct |
21 |
Correct |
61 ms |
157592 KB |
Output is correct |
22 |
Correct |
142 ms |
158116 KB |
Output is correct |
23 |
Correct |
146 ms |
158016 KB |
Output is correct |
24 |
Correct |
137 ms |
158196 KB |
Output is correct |
25 |
Correct |
140 ms |
158104 KB |
Output is correct |
26 |
Correct |
132 ms |
158112 KB |
Output is correct |
27 |
Correct |
193 ms |
158184 KB |
Output is correct |
28 |
Correct |
200 ms |
158028 KB |
Output is correct |
29 |
Correct |
184 ms |
158120 KB |
Output is correct |
30 |
Correct |
189 ms |
158080 KB |
Output is correct |
31 |
Correct |
199 ms |
158116 KB |
Output is correct |
32 |
Correct |
234 ms |
158136 KB |
Output is correct |
33 |
Correct |
243 ms |
158116 KB |
Output is correct |
34 |
Correct |
225 ms |
158108 KB |
Output is correct |
35 |
Correct |
228 ms |
158160 KB |
Output is correct |
36 |
Correct |
241 ms |
158120 KB |
Output is correct |