Submission #531955

# Submission time Handle Problem Language Result Execution time Memory
531955 2022-03-02T01:31:12 Z Deepesson Nautilus (BOI19_nautilus) C++17
100 / 100
195 ms 708 KB
#include <bits/stdc++.h>
#define MAX 505
typedef std::bitset<MAX> bits;
std::deque<bits> deq;
int R,C,M;
std::string comandos;
bits mapa[MAX];
bits em={};
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    std::cin>>R>>C>>M;
    for(int i=0;i!=R;++i){
        bits x={};
        std::string s;
        std::cin >> s;
        for(int j=0;j!=C;++j){
            if(s[j]!='#')x[j]=1;
        }
        mapa[i]=x;
    }
    for(int i=0;i!=R;++i){
        bits x=mapa[i];
        deq.push_back(x);
    }
    std::cin>>comandos;
    for(int i=0;i!=M;++i){
        char ch = comandos[i];
        switch(ch){
            ///direita
            case 'W':{
                for(int i=0;i!=R;++i){
                    deq[i]=(deq[i]>>1)&mapa[i];
                }
            }break;

            ///esquerda
            case 'E':{
                for(int i=0;i!=R;++i){
                    deq[i]=(deq[i]<<1)&mapa[i];
                }
            }break;

            ///norte:
            case 'N':{
                for(int i=0;i!=R-1;++i){
                    deq[i]=(deq[i+1])&mapa[i];
                }
                deq[R-1]=em;
            }break;

            ///sul
            case 'S':{
                for(int i=R-1;i!=0;--i){
                    deq[i]=(deq[i-1])&mapa[i];
                }
                deq[0]=em;
            }break;

            ///coringa
            case '?':{
                std::deque<bits> nov;
                for(int i=0;i!=R;++i){
                    bits x={};
                    nov.push_back(x);
                }
                for(int i=0;i!=R;++i){
                    nov[i]|=(deq[i]>>1)&mapa[i];
                }
                for(int i=0;i!=R;++i){
                    nov[i]|=(deq[i]<<1)&mapa[i];
                }
                for(int i=0;i!=R-1;++i){
                    nov[i]|=(deq[i+1])&mapa[i];
                }
                for(int i=1;i!=R;++i){
                    nov[i]|=(deq[i-1])&mapa[i];
                }
                deq=nov;
            }break;
        }
    }
    int count=0;
    for(auto&x:deq)count+=x.count();
    std::cout<<count<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 85 ms 588 KB Output is correct
23 Correct 83 ms 668 KB Output is correct
24 Correct 82 ms 588 KB Output is correct
25 Correct 96 ms 672 KB Output is correct
26 Correct 78 ms 580 KB Output is correct
27 Correct 133 ms 668 KB Output is correct
28 Correct 137 ms 588 KB Output is correct
29 Correct 142 ms 708 KB Output is correct
30 Correct 138 ms 580 KB Output is correct
31 Correct 136 ms 668 KB Output is correct
32 Correct 195 ms 668 KB Output is correct
33 Correct 185 ms 668 KB Output is correct
34 Correct 180 ms 552 KB Output is correct
35 Correct 190 ms 668 KB Output is correct
36 Correct 187 ms 588 KB Output is correct