Submission #242856

# Submission time Handle Problem Language Result Execution time Memory
242856 2020-06-29T12:42:22 Z oolimry Nautilus (BOI19_nautilus) C++14
100 / 100
188 ms 888 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 501;
bitset<MAXN> cur[MAXN];
bitset<MAXN> temp[MAXN];
bitset<MAXN> walls[MAXN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int rows, cols, K; cin >> rows >> cols >> K;
	
	for(int r = 0;r < rows;r++){
		string s; cin >> s;
		for(int c = 0;c < cols;c++){
			int bit = (s[c] == '.');
			cur[r][c] = bit;
			walls[r][c] = bit;
		}
	}
	
	string command; cin >> command;
	for(char c : command){
		
		
		if(c == 'W'){
			for(int r = 0;r < rows;r++) cur[r] >>= 1;
		}
		if(c == 'E'){
			for(int r = 0;r < rows;r++) cur[r] <<= 1;
		}
		if(c == 'N'){
			for(int r = 0;r < rows-1;r++) cur[r] = cur[r+1];
			for(int c = 0;c < cols;c++) cur[rows-1][c] = 0;
		}
		if(c == 'S'){
			for(int r = rows-1;r >= 1;r--) cur[r] = cur[r-1];
			for(int c = 0;c < cols;c++) cur[0][c] = 0;
		}
		if(c == '?'){
			for(int r = 0;r < rows;r++) temp[r] = cur[r];
			
			for(int r = 0;r < rows;r++){
				cur[r] = (temp[r] << 1) | (temp[r] >> 1);
				if(r != 0) cur[r] |= temp[r-1];
				if(r != rows-1) cur[r] |= temp[r+1];
			}
		}
		
		
		for(int r = 0;r < rows;r++) cur[r] &= walls[r];
		
	}
	
	int ans = 0;
	for(int r = 0;r < rows;r++){
		for(int c = 0;c < cols;c++){
			ans += cur[r][c];
		}
	}
	
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 77 ms 768 KB Output is correct
23 Correct 74 ms 640 KB Output is correct
24 Correct 77 ms 760 KB Output is correct
25 Correct 73 ms 640 KB Output is correct
26 Correct 71 ms 640 KB Output is correct
27 Correct 114 ms 640 KB Output is correct
28 Correct 115 ms 640 KB Output is correct
29 Correct 112 ms 760 KB Output is correct
30 Correct 112 ms 768 KB Output is correct
31 Correct 128 ms 740 KB Output is correct
32 Correct 152 ms 640 KB Output is correct
33 Correct 164 ms 768 KB Output is correct
34 Correct 147 ms 888 KB Output is correct
35 Correct 150 ms 768 KB Output is correct
36 Correct 188 ms 864 KB Output is correct