#pragma GCC target("popcnt")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int R, C, M;
string s;
char c[501][501];
bitset<250000> org, cur, E, W;
int id(int i, int j) {
return i * C + j;
}
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> R >> C >> M;
for (int i = 0; i < R; i++)
for (int j = 0; j < C; j++) {
cin >> c[i][j];
int pos = id(i, j);
if (c[i][j] == '.') {
org.set(pos);
cur.set(pos);
}
if (j != C - 1) W.set(pos);
if (j != 0) E.set(pos);
}
cin >> s;
for (int i = 0; i < M; i++) {
if (s[i] == 'N')
cur = (cur >> C);
else if (s[i] == 'S')
cur = (cur << C);
else if (s[i] == 'W')
cur = (cur >> 1) & W;
else if (s[i] == 'E')
cur = (cur << 1) & E;
else
cur = ((cur >> C) | (cur << C) | ((cur >> 1) & W) | ((cur << 1) & E));
cur &= org;
}
cout << cur.count();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
3 ms |
588 KB |
Output is correct |
7 |
Correct |
3 ms |
588 KB |
Output is correct |
8 |
Correct |
4 ms |
588 KB |
Output is correct |
9 |
Correct |
3 ms |
588 KB |
Output is correct |
10 |
Correct |
3 ms |
588 KB |
Output is correct |
11 |
Correct |
3 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
15 |
Correct |
5 ms |
588 KB |
Output is correct |
16 |
Correct |
4 ms |
588 KB |
Output is correct |
17 |
Correct |
5 ms |
588 KB |
Output is correct |
18 |
Correct |
6 ms |
588 KB |
Output is correct |
19 |
Correct |
5 ms |
588 KB |
Output is correct |
20 |
Correct |
5 ms |
588 KB |
Output is correct |
21 |
Correct |
6 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
3 ms |
588 KB |
Output is correct |
7 |
Correct |
3 ms |
588 KB |
Output is correct |
8 |
Correct |
4 ms |
588 KB |
Output is correct |
9 |
Correct |
3 ms |
588 KB |
Output is correct |
10 |
Correct |
3 ms |
588 KB |
Output is correct |
11 |
Correct |
3 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
15 |
Correct |
5 ms |
588 KB |
Output is correct |
16 |
Correct |
4 ms |
588 KB |
Output is correct |
17 |
Correct |
5 ms |
588 KB |
Output is correct |
18 |
Correct |
6 ms |
588 KB |
Output is correct |
19 |
Correct |
5 ms |
588 KB |
Output is correct |
20 |
Correct |
5 ms |
588 KB |
Output is correct |
21 |
Correct |
6 ms |
588 KB |
Output is correct |
22 |
Correct |
101 ms |
844 KB |
Output is correct |
23 |
Correct |
99 ms |
844 KB |
Output is correct |
24 |
Correct |
98 ms |
948 KB |
Output is correct |
25 |
Correct |
111 ms |
948 KB |
Output is correct |
26 |
Correct |
96 ms |
844 KB |
Output is correct |
27 |
Correct |
157 ms |
948 KB |
Output is correct |
28 |
Correct |
158 ms |
952 KB |
Output is correct |
29 |
Correct |
165 ms |
944 KB |
Output is correct |
30 |
Correct |
159 ms |
960 KB |
Output is correct |
31 |
Correct |
159 ms |
944 KB |
Output is correct |
32 |
Correct |
201 ms |
956 KB |
Output is correct |
33 |
Correct |
207 ms |
944 KB |
Output is correct |
34 |
Correct |
206 ms |
956 KB |
Output is correct |
35 |
Correct |
203 ms |
944 KB |
Output is correct |
36 |
Correct |
206 ms |
844 KB |
Output is correct |