#include <iostream>
#include <bitset>
#include <vector>
#include <array>
int R,C,M;
struct Board
{
std::bitset<512> board[512];
void init()
{
for(int i = 0; i < R; i++)
{
for(int j = 0; j < C; j++)
{
char c;
std::cin >> c;
board[i+1][j+1] = c=='.';
}
}
}
};
int main()
{
std::cin >> R >> C >> M;
Board board; board.init();
Board poss = board;
for(int i = 0; i < M; i++)
{
char c; std::cin >> c;
if(c=='?')
{
Board next;
for(int i = 1; i <= R;i++) next.board[i] |= poss.board[i+1] & board.board[i];
for(int i = R; i >= 1; i--) next.board[i] |= poss.board[i-1] & board.board[i];
for(int i = 1; i <= R; i++) next.board[i] |= (poss.board[i] << 1) & board.board[i];
for(int i = 1; i <= R; i++) next.board[i] |= (poss.board[i] >> 1) & board.board[i];
poss = next;
continue;
}
switch (c)
{
case 'N':
for(int i = 1; i <= R;i++) poss.board[i] = poss.board[i+1] & board.board[i];
break;
case 'S':
for(int i = R; i >= 1; i--) poss.board[i] = poss.board[i-1] & board.board[i];
break;
case 'E':
for(int i = 1; i <= R; i++) poss.board[i] = (poss.board[i] << 1) & board.board[i];
break;
case 'W':
for(int i = 1; i <= R; i++) poss.board[i] = (poss.board[i] >> 1) & board.board[i];
break;
}
}
int o = 0;
for(auto& i : poss.board) o+=i.count();
std::cout << o << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
528 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
528 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
528 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
67 ms |
604 KB |
Output is correct |
23 |
Correct |
70 ms |
600 KB |
Output is correct |
24 |
Correct |
67 ms |
604 KB |
Output is correct |
25 |
Correct |
67 ms |
604 KB |
Output is correct |
26 |
Correct |
64 ms |
600 KB |
Output is correct |
27 |
Correct |
114 ms |
752 KB |
Output is correct |
28 |
Correct |
115 ms |
752 KB |
Output is correct |
29 |
Correct |
103 ms |
756 KB |
Output is correct |
30 |
Correct |
109 ms |
848 KB |
Output is correct |
31 |
Correct |
102 ms |
748 KB |
Output is correct |
32 |
Correct |
128 ms |
752 KB |
Output is correct |
33 |
Correct |
133 ms |
756 KB |
Output is correct |
34 |
Correct |
150 ms |
756 KB |
Output is correct |
35 |
Correct |
130 ms |
600 KB |
Output is correct |
36 |
Correct |
130 ms |
604 KB |
Output is correct |