Submission #531960

# Submission time Handle Problem Language Result Execution time Memory
531960 2022-03-02T01:45:32 Z Deepesson Nautilus (BOI19_nautilus) C++17
100 / 100
230 ms 420 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){
			///Right
			case 'W':{
				for(int i=0;i!=R;++i){
					deq[i]=(deq[i]>>1)&mapa[i];
				}
			}break;

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

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

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

			///Mystery
			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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 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 332 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 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 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 332 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 332 KB Output is correct
22 Correct 87 ms 412 KB Output is correct
23 Correct 112 ms 320 KB Output is correct
24 Correct 101 ms 412 KB Output is correct
25 Correct 81 ms 416 KB Output is correct
26 Correct 81 ms 416 KB Output is correct
27 Correct 151 ms 420 KB Output is correct
28 Correct 145 ms 420 KB Output is correct
29 Correct 143 ms 416 KB Output is correct
30 Correct 161 ms 416 KB Output is correct
31 Correct 139 ms 416 KB Output is correct
32 Correct 193 ms 416 KB Output is correct
33 Correct 203 ms 416 KB Output is correct
34 Correct 189 ms 416 KB Output is correct
35 Correct 230 ms 412 KB Output is correct
36 Correct 205 ms 412 KB Output is correct