Submission #926127

# Submission time Handle Problem Language Result Execution time Memory
926127 2024-02-12T15:14:37 Z pragmatist Nautilus (BOI19_nautilus) C++17
100 / 100
150 ms 1364 KB
#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>
#include<iomanip>
#include<bitset>

using namespace std;

const int N = (int)4e5 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7; 

int mult(int x, int y) {
	return 1ll*x*y%MOD;
}

int sum(int x, int y) {
	x += y;
	if(x >= MOD) {
		x -= MOD;
	}
	return x;
}

int sub(int x, int y) {
	x -= y;
	if(x < 0) {
		x += MOD;
	}
	return x;
}

int n, m, k;

vector<pair<int, int> > dir[300];

void init() {
	dir['W'] = {{0, -1}};
	dir['E'] = {{0, +1}};
	dir['N'] = {{-1, 0}};
	dir['S'] = {{+1, 0}};
	dir['?'] = {{0, -1}, {0, +1}, {-1, 0}, {+1, 0}};
}

int main() {	
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	init();
	cin >> n >> m >> k;
	char a[n+1][m+1];
	bool is[n+1][m+1];
	bitset<505> used[2][501];
	bitset<505> block[501];
	memset(is, 0, sizeof(is));
	for(int i = 0; i < n; ++i) {
		used[1][i].reset();
		for(int j = 0; j < m; ++j) {
			cin >> a[i][j];
			if(a[i][j] == '.') {
				used[0][i][j]=1;
			} else {
				block[i][j]=1;
			}
		}
	}
	string s;
	cin >> s;
	s = '#'+s;
	for(int id = 1; id <= k; ++id) {
		if(s[id] == 'W' || s[id] == '?') {
			for(int i = 0; i < n; ++i) {
				used[1][i] |= (used[0][i]>>1);
			}			
		}
		if(s[id] == 'E' || s[id] == '?') {
			for(int i = 0; i < n; ++i) {
				used[1][i] |= (used[0][i]<<1);
			}
		}
		if(s[id] == 'N' || s[id] == '?') {
			for(int i = 0; i < n-1; ++i) {
				used[1][i] |= used[0][i+1];		
			}
		}
		if(s[id] == 'S' || s[id] == '?') {
			for(int i = 1; i < n; ++i) {
				used[1][i] |= used[0][i-1];
			}
		}
		for(int i = 0; i < n; ++i) {
			used[1][i] |= block[i];
			used[1][i] ^= block[i];
	    	used[0][i] = used[1][i];    
	    	used[0][i][m] = 0;
	    	used[1][i].reset();
		}
	}
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(used[0][i][j]) {
				assert(a[i][j] == '.');
			}
			ans += used[0][i][j];
		}
	}
	cout << ans << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 560 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 560 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 92 ms 1288 KB Output is correct
23 Correct 93 ms 1116 KB Output is correct
24 Correct 91 ms 1112 KB Output is correct
25 Correct 92 ms 1284 KB Output is correct
26 Correct 90 ms 1116 KB Output is correct
27 Correct 121 ms 1112 KB Output is correct
28 Correct 125 ms 1288 KB Output is correct
29 Correct 125 ms 1288 KB Output is correct
30 Correct 125 ms 1364 KB Output is correct
31 Correct 121 ms 1120 KB Output is correct
32 Correct 146 ms 1112 KB Output is correct
33 Correct 147 ms 1116 KB Output is correct
34 Correct 150 ms 1284 KB Output is correct
35 Correct 146 ms 1116 KB Output is correct
36 Correct 148 ms 1284 KB Output is correct