#include <iostream>
#include <bitset>
using namespace std;
using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
int const nmax = 500;
char v[1 + nmax][1 + nmax];
char mv[1 + nmax * 10];
int main()
{
int n, m, moves;
cin >> n >> m >> moves;
bitset<nmax * (nmax + 1)> sol, possible;
for(int i = 1;i <= n; i++)
for(int j = 1;j <= m; j++) {
cin >> v[i][j];
if(v[i][j] == '.')
sol[(i - 1) * (m + 1) + j] = 1;
}
possible = sol;
for(int i = 1;i <= moves; i++)
cin >> mv[i];
for(int i = 1; i <= moves; i++){
if(mv[i] == 'N')
sol = (sol >> (m + 1)) & possible;
else if(mv[i] == 'S')
sol = (sol << (m + 1)) & possible;
else if(mv[i] == 'W')
sol = (sol >> 1) & possible;
else if(mv[i] == 'E')
sol = (sol << 1) & possible;
else{
sol = ((sol >> (m + 1)) | (sol << (m + 1)) | (sol >> 1) | (sol << 1)) & possible;
}
}
cout << sol.count();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
636 KB |
Output is correct |
7 |
Correct |
7 ms |
1016 KB |
Output is correct |
8 |
Correct |
7 ms |
888 KB |
Output is correct |
9 |
Correct |
7 ms |
760 KB |
Output is correct |
10 |
Correct |
7 ms |
760 KB |
Output is correct |
11 |
Correct |
6 ms |
760 KB |
Output is correct |
12 |
Correct |
9 ms |
760 KB |
Output is correct |
13 |
Correct |
8 ms |
760 KB |
Output is correct |
14 |
Correct |
8 ms |
860 KB |
Output is correct |
15 |
Correct |
8 ms |
888 KB |
Output is correct |
16 |
Correct |
8 ms |
764 KB |
Output is correct |
17 |
Correct |
10 ms |
632 KB |
Output is correct |
18 |
Correct |
9 ms |
632 KB |
Output is correct |
19 |
Correct |
10 ms |
632 KB |
Output is correct |
20 |
Correct |
10 ms |
632 KB |
Output is correct |
21 |
Correct |
9 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
636 KB |
Output is correct |
7 |
Correct |
7 ms |
1016 KB |
Output is correct |
8 |
Correct |
7 ms |
888 KB |
Output is correct |
9 |
Correct |
7 ms |
760 KB |
Output is correct |
10 |
Correct |
7 ms |
760 KB |
Output is correct |
11 |
Correct |
6 ms |
760 KB |
Output is correct |
12 |
Correct |
9 ms |
760 KB |
Output is correct |
13 |
Correct |
8 ms |
760 KB |
Output is correct |
14 |
Correct |
8 ms |
860 KB |
Output is correct |
15 |
Correct |
8 ms |
888 KB |
Output is correct |
16 |
Correct |
8 ms |
764 KB |
Output is correct |
17 |
Correct |
10 ms |
632 KB |
Output is correct |
18 |
Correct |
9 ms |
632 KB |
Output is correct |
19 |
Correct |
10 ms |
632 KB |
Output is correct |
20 |
Correct |
10 ms |
632 KB |
Output is correct |
21 |
Correct |
9 ms |
632 KB |
Output is correct |
22 |
Correct |
183 ms |
1308 KB |
Output is correct |
23 |
Correct |
189 ms |
1284 KB |
Output is correct |
24 |
Correct |
185 ms |
1308 KB |
Output is correct |
25 |
Correct |
185 ms |
1316 KB |
Output is correct |
26 |
Correct |
180 ms |
1312 KB |
Output is correct |
27 |
Correct |
271 ms |
1308 KB |
Output is correct |
28 |
Correct |
274 ms |
1312 KB |
Output is correct |
29 |
Correct |
272 ms |
1276 KB |
Output is correct |
30 |
Correct |
273 ms |
1400 KB |
Output is correct |
31 |
Correct |
271 ms |
1272 KB |
Output is correct |
32 |
Correct |
334 ms |
1144 KB |
Output is correct |
33 |
Correct |
333 ms |
1144 KB |
Output is correct |
34 |
Correct |
340 ms |
1144 KB |
Output is correct |
35 |
Correct |
332 ms |
1276 KB |
Output is correct |
36 |
Correct |
332 ms |
1144 KB |
Output is correct |