제출 #972006

#제출 시각아이디문제언어결과실행 시간메모리
972006canadavid1Nautilus (BOI19_nautilus)C++14
100 / 100
150 ms848 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...