Submission #163348

# Submission time Handle Problem Language Result Execution time Memory
163348 2019-11-12T18:14:46 Z Saboon Nautilus (BOI19_nautilus) C++14
100 / 100
205 ms 772 KB
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 500;
const int inf = 1e9;
 
bitset<maxn> dp[2][maxn], sea[maxn];
 
int main(){
	ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		for (int j = 0; j < m; j++){
			if (s[j] == '.')
				sea[i][j] = 1;
			else
				sea[i][j] = 0;
		}
	}
	string s;
	cin >> s;
	for (int i = 0; i < n; i++)
		dp[0][i] = sea[i];
 
	for (int x = 1; x <= k; x++){
		int p = (x & 1);
		for (int i = 0; i < n; i++)
			dp[p][i].reset();
		if (s[x - 1] == 'N' or s[x - 1] == '?'){
			for (int i = 0; i < n - 1; i++)
				dp[p][i] |= (dp[1 - p][i + 1] & sea[i]);
		}
		if (s[x - 1] == 'S' or s[x - 1] == '?'){
			for (int i = 1; i < n; i++)
				dp[p][i] |= (dp[1 - p][i - 1] & sea[i]);
		}
		if (s[x - 1] == 'E' or s[x - 1] == '?'){
			for (int i = 0; i < n; i++)
				dp[p][i] |= ((dp[1 - p][i] << 1) & sea[i]);
		}
		if (s[x - 1] == 'W' or s[x - 1] == '?'){
			for (int i = 0; i < n; i++)
				dp[p][i] |= ((dp[1 - p][i] >> 1) & sea[i]);
		}
	}
	int p = (k & 1);
	int cnt = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (dp[p][i][j])
				cnt ++;
	cout << cnt << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 388 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 388 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 380 KB Output is correct
22 Correct 103 ms 760 KB Output is correct
23 Correct 105 ms 736 KB Output is correct
24 Correct 103 ms 760 KB Output is correct
25 Correct 101 ms 760 KB Output is correct
26 Correct 101 ms 736 KB Output is correct
27 Correct 158 ms 760 KB Output is correct
28 Correct 162 ms 744 KB Output is correct
29 Correct 159 ms 632 KB Output is correct
30 Correct 161 ms 772 KB Output is correct
31 Correct 158 ms 656 KB Output is correct
32 Correct 204 ms 632 KB Output is correct
33 Correct 203 ms 760 KB Output is correct
34 Correct 205 ms 760 KB Output is correct
35 Correct 205 ms 760 KB Output is correct
36 Correct 204 ms 772 KB Output is correct