This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |