Submission #276746

# Submission time Handle Problem Language Result Execution time Memory
276746 2020-08-20T16:00:38 Z manh9203 Nautilus (BOI19_nautilus) C++17
100 / 100
195 ms 1016 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 505;

int n, m, k;
char c[N][N];
bitset<N> init[N];
bitset<N> dp[N][2];
string s;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> c[i][j];
			if (c[i][j] == '.') init[i].set(j);
		}
		dp[i][1] = init[i];
	}
	cin >> s;

	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= n; j++) {
			dp[j][0] = dp[j][1];
			dp[j][1].reset();
		}
		for (int j = 1; j <= n; j++) {
			if (s[i - 1] == 'W') dp[j][1] |= (dp[j][0] >> 1);
			if (s[i - 1] == 'E') dp[j][1] |= (dp[j][0] << 1);
			if (s[i - 1] == 'N') dp[j][1] |= dp[j + 1][0];
			if (s[i - 1] == 'S') dp[j][1] |= dp[j - 1][0];
			if (s[i - 1] == '?') {
				dp[j][1] |= (dp[j][0] >> 1);
				dp[j][1] |= (dp[j][0] << 1);
				dp[j][1] |= dp[j + 1][0];
				dp[j][1] |= dp[j - 1][0];
			}
			dp[j][1] &= init[j];
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= n; i++) ans += dp[i][1].count();
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 396 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 396 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 118 ms 896 KB Output is correct
23 Correct 125 ms 996 KB Output is correct
24 Correct 113 ms 992 KB Output is correct
25 Correct 128 ms 888 KB Output is correct
26 Correct 122 ms 1016 KB Output is correct
27 Correct 151 ms 892 KB Output is correct
28 Correct 153 ms 896 KB Output is correct
29 Correct 155 ms 1016 KB Output is correct
30 Correct 153 ms 896 KB Output is correct
31 Correct 158 ms 896 KB Output is correct
32 Correct 179 ms 896 KB Output is correct
33 Correct 182 ms 896 KB Output is correct
34 Correct 190 ms 896 KB Output is correct
35 Correct 183 ms 996 KB Output is correct
36 Correct 195 ms 896 KB Output is correct