Submission #199810

# Submission time Handle Problem Language Result Execution time Memory
199810 2020-02-03T13:23:48 Z Fischer Nautilus (BOI19_nautilus) C++14
100 / 100
295 ms 157944 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 502;
const int maxm = 5002;
bitset<maxn> dp[maxn][maxm], sea[maxn];
int n, m, k;
string s[maxn];
string p;

int main() {
	cin >> n >> m >> k;
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		for (int j = 0; j < m; ++j) {
			sea[i][j] = s[i][j] != '#';
		}
	}
	for (int i = 0; i < n; ++i) {
		dp[i][0] = sea[i];
	}
	cin >> p;
	for (int t = 0; t < k; ++t) {
		if (p[t] == 'S') {
			for (int i = 1; i < n; ++i) {
				dp[i][t+1] = dp[i-1][t] & sea[i];
			}	
		} else if (p[t] == 'N') {
			for (int i = 0; i < n; ++i) {
				dp[i][t+1] = dp[i+1][t] & sea[i];
			}
		} else if (p[t] == 'W') {
			for (int i = 0; i < n; ++i) {
				dp[i][t+1] = (dp[i][t] >> 1) & sea[i];
			}			
		} else if (p[t] == 'E') {
			for (int i = 0; i < n; ++i) {
				dp[i][t+1] = (dp[i][t] << 1) & sea[i];
			}
		} else {
			dp[0][t+1] = ((dp[0][t] << 1) 
						| (dp[0][t] >> 1) 
						| (dp[1][t]))
						& sea[0];
			for (int i = 1; i < n; ++i) {
				dp[i][t+1] = ((dp[i][t] << 1)
						| (dp[i][t] >> 1)
						| (dp[i-1][t])
						| (dp[i+1][t]))
						& sea[i];
			}
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cnt += dp[i][k][j] == 1;
		}
	}
	cout << cnt << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1400 KB Output is correct
2 Correct 6 ms 1528 KB Output is correct
3 Correct 6 ms 1528 KB Output is correct
4 Correct 6 ms 1400 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 6 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1400 KB Output is correct
2 Correct 6 ms 1528 KB Output is correct
3 Correct 6 ms 1528 KB Output is correct
4 Correct 6 ms 1400 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 6 ms 1400 KB Output is correct
7 Correct 6 ms 1400 KB Output is correct
8 Correct 7 ms 1528 KB Output is correct
9 Correct 7 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 7 ms 1400 KB Output is correct
13 Correct 7 ms 1400 KB Output is correct
14 Correct 6 ms 1400 KB Output is correct
15 Correct 7 ms 1400 KB Output is correct
16 Correct 7 ms 1400 KB Output is correct
17 Correct 7 ms 1400 KB Output is correct
18 Correct 7 ms 1528 KB Output is correct
19 Correct 7 ms 1400 KB Output is correct
20 Correct 7 ms 1528 KB Output is correct
21 Correct 7 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1400 KB Output is correct
2 Correct 6 ms 1528 KB Output is correct
3 Correct 6 ms 1528 KB Output is correct
4 Correct 6 ms 1400 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 6 ms 1400 KB Output is correct
7 Correct 6 ms 1400 KB Output is correct
8 Correct 7 ms 1528 KB Output is correct
9 Correct 7 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 7 ms 1400 KB Output is correct
13 Correct 7 ms 1400 KB Output is correct
14 Correct 6 ms 1400 KB Output is correct
15 Correct 7 ms 1400 KB Output is correct
16 Correct 7 ms 1400 KB Output is correct
17 Correct 7 ms 1400 KB Output is correct
18 Correct 7 ms 1528 KB Output is correct
19 Correct 7 ms 1400 KB Output is correct
20 Correct 7 ms 1528 KB Output is correct
21 Correct 7 ms 1528 KB Output is correct
22 Correct 189 ms 157688 KB Output is correct
23 Correct 200 ms 157688 KB Output is correct
24 Correct 188 ms 157808 KB Output is correct
25 Correct 183 ms 157688 KB Output is correct
26 Correct 180 ms 157816 KB Output is correct
27 Correct 244 ms 157688 KB Output is correct
28 Correct 244 ms 157688 KB Output is correct
29 Correct 247 ms 157688 KB Output is correct
30 Correct 242 ms 157688 KB Output is correct
31 Correct 267 ms 157944 KB Output is correct
32 Correct 285 ms 157688 KB Output is correct
33 Correct 294 ms 157816 KB Output is correct
34 Correct 295 ms 157688 KB Output is correct
35 Correct 285 ms 157688 KB Output is correct
36 Correct 292 ms 157816 KB Output is correct