#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define oo 1e9
#define pii pair<int, int>
using namespace std;
int n, m, q;
const int MAX = 505;
bitset<MAX * MAX> st, can;
int main()
{
cin >> n >> m >> q;
for (int i = 0; i < n; i++)
{
string s; cin >> s;
can[i * (m + 2)] = 0;
can[(i + 1) * (m + 2) - 1] = 0;
for (int j = 1; j <= m; j++)
{
can[i * (m + 2) + j] = s[j - 1] == '.';
}
}
st = can;
string s; cin >> s;
for (int i = 0; i < q; i++)
{
if(s[i] == 'W'){
st >>= 1;
}
else if(s[i] == 'S'){
st <<= m + 2;
}
else if(s[i] == 'E'){
st <<= 1;
}
else if(s[i] == 'N'){
st >>= m + 2;
}
else{
st = (st << 1) | (st >> 1) | (st << (m + 2)) | (st >> (m + 2));
}
st &= can;
}
cout << st.count() << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
44 ms |
468 KB |
Output is correct |
23 |
Correct |
47 ms |
468 KB |
Output is correct |
24 |
Correct |
43 ms |
468 KB |
Output is correct |
25 |
Correct |
43 ms |
572 KB |
Output is correct |
26 |
Correct |
43 ms |
468 KB |
Output is correct |
27 |
Correct |
73 ms |
572 KB |
Output is correct |
28 |
Correct |
75 ms |
568 KB |
Output is correct |
29 |
Correct |
76 ms |
568 KB |
Output is correct |
30 |
Correct |
74 ms |
468 KB |
Output is correct |
31 |
Correct |
75 ms |
468 KB |
Output is correct |
32 |
Correct |
97 ms |
568 KB |
Output is correct |
33 |
Correct |
105 ms |
572 KB |
Output is correct |
34 |
Correct |
99 ms |
568 KB |
Output is correct |
35 |
Correct |
95 ms |
468 KB |
Output is correct |
36 |
Correct |
95 ms |
468 KB |
Output is correct |