답안 #529967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529967 2022-02-24T07:54:37 Z c28dnv9q3 Nautilus (BOI19_nautilus) C++17
100 / 100
203 ms 644 KB
#include <bits/stdc++.h>

std::bitset<505> map[505];
std::bitset<505> pos[505];
std::bitset<505> _pos[505];
std::vector<char> cmds;

int main ()
{
    int R, C, M;
    std::cin >> R >> C >> M;
    for(int row = 1; row <= R; row++)
        for(int col = C; col >= 1; col--)
        {
            char c = ' ';
            while(c != '#' && c != '.')
                c = std::getchar();
            map[row][col] = (c == '#') ? 0 : 1;
            pos[row][col] = (c == '#') ? 0 : 1;
        }
    for(int i = 0; i < M; i++)
    {
        char c = ' ';
        while(c != 'N' && c != 'E' && c != 'S' && c != 'W' && c != '?')
            c = std::getchar();
        cmds.push_back(c);
    }

    for(int cmd = 0; cmd < M; cmd++)
    {
        switch(cmds[cmd])
        {
            case 'N':
                for(int i = 1; i <= R; i++)
                    pos[i] = pos[i+1] & map[i];
            break;

            case 'E':
                for(int i = 1; i <= R; i++)
                    pos[i] = (pos[i] >> 1) & map[i];
            break;

            case 'S':
                for(int i = R; i >= 1; i--)
                    pos[i] = pos[i-1] & map[i];
            break;
            
            case 'W':
                for(int i = 1; i <= R; i++)
                    pos[i] = (pos[i] << 1) & map[i];
            break;
            
            case '?':
                for(int i = 1; i <= R; i++)
                    _pos[i] = pos[i];
                for(int i = 1; i <= R; i++)
                    pos[i] = (_pos[i+1] & map[i]) 
                            | ((_pos[i] << 1) & map[i]) 
                            | (_pos[i-1] & map[i]) 
                            | ((_pos[i] >> 1) & map[i]);
            break;
        }

        // std::cout << cmds[cmd] << "\n";
        // for(int row = 1; row <= R; row++)
        // {
        //     for(int col = C; col >= 1; col--)
        //     {
        //         if(map[row][col])
        //             std::cout << pos[row][col];
        //         else
        //             std::cout << "#";
        //     }    
        //     std::cout << "\n";
        // }
        // std::cout << "\n";

    }
    
    int sum = 0;
    for(int r = 1; r <= R; r++)
        sum += pos[r].count();

    std::cout << sum;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 216 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 216 KB Output is correct
14 Correct 1 ms 216 KB Output is correct
15 Correct 1 ms 216 KB Output is correct
16 Correct 2 ms 216 KB Output is correct
17 Correct 1 ms 216 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 1 ms 216 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 216 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 216 KB Output is correct
14 Correct 1 ms 216 KB Output is correct
15 Correct 1 ms 216 KB Output is correct
16 Correct 2 ms 216 KB Output is correct
17 Correct 1 ms 216 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 1 ms 216 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 216 KB Output is correct
22 Correct 82 ms 576 KB Output is correct
23 Correct 85 ms 536 KB Output is correct
24 Correct 82 ms 628 KB Output is correct
25 Correct 90 ms 632 KB Output is correct
26 Correct 78 ms 600 KB Output is correct
27 Correct 134 ms 632 KB Output is correct
28 Correct 145 ms 636 KB Output is correct
29 Correct 143 ms 644 KB Output is correct
30 Correct 138 ms 628 KB Output is correct
31 Correct 133 ms 636 KB Output is correct
32 Correct 203 ms 632 KB Output is correct
33 Correct 191 ms 632 KB Output is correct
34 Correct 187 ms 632 KB Output is correct
35 Correct 181 ms 596 KB Output is correct
36 Correct 181 ms 628 KB Output is correct