Submission #477502

# Submission time Handle Problem Language Result Execution time Memory
477502 2021-10-02T10:34:11 Z Sohsoh84 Nautilus (BOI19_nautilus) C++17
100 / 100
245 ms 900 KB
// ¯\_(ツ)_/¯
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
 
#define all(x)                      (x).begin(),(x).end()
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << ": " <<  x << endl;
 
const ll MAXN = 500 + 3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;
 
int n, m, l;
bitset<MAXN * MAXN> dp[MAXN], G, W, E;
string s;
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m >> l;
 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			G[i * m + j] = (c == '.');
			W[i * m + j] = E[i * m + j] = true;
		}
 
		W[i * m + m - 1] = false;
		E[i * m] = false;
	}
 
	cin >> s;
	s = "." + s;
	dp[0] = G;
	
	for (int i = 1; i <= l; i++) {
		int ind = i & 1;
		dp[ind].reset();
 
		if (s[i] == 'N' || s[i] == '?') dp[ind] |= (dp[1 - ind] >> m);
		if (s[i] == 'S' || s[i] == '?') dp[ind] |= (dp[1 - ind] << m);
		if (s[i] == 'E' || s[i] == '?') dp[ind] |= ((dp[1 - ind] << 1) & E);
		if (s[i] == 'W' || s[i] == '?') dp[ind] |= ((dp[1 - ind] >> 1) & W);
		dp[ind] &= G;
	}
 
	cout << dp[l & 1].count() << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 464 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 464 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 464 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 4 ms 392 KB Output is correct
10 Correct 4 ms 464 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 4 ms 464 KB Output is correct
13 Correct 6 ms 464 KB Output is correct
14 Correct 4 ms 464 KB Output is correct
15 Correct 4 ms 464 KB Output is correct
16 Correct 5 ms 464 KB Output is correct
17 Correct 6 ms 464 KB Output is correct
18 Correct 6 ms 464 KB Output is correct
19 Correct 7 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 464 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 464 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 4 ms 392 KB Output is correct
10 Correct 4 ms 464 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 4 ms 464 KB Output is correct
13 Correct 6 ms 464 KB Output is correct
14 Correct 4 ms 464 KB Output is correct
15 Correct 4 ms 464 KB Output is correct
16 Correct 5 ms 464 KB Output is correct
17 Correct 6 ms 464 KB Output is correct
18 Correct 6 ms 464 KB Output is correct
19 Correct 7 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 5 ms 380 KB Output is correct
22 Correct 121 ms 780 KB Output is correct
23 Correct 133 ms 776 KB Output is correct
24 Correct 143 ms 780 KB Output is correct
25 Correct 121 ms 780 KB Output is correct
26 Correct 122 ms 900 KB Output is correct
27 Correct 193 ms 720 KB Output is correct
28 Correct 188 ms 720 KB Output is correct
29 Correct 222 ms 780 KB Output is correct
30 Correct 196 ms 764 KB Output is correct
31 Correct 193 ms 776 KB Output is correct
32 Correct 245 ms 776 KB Output is correct
33 Correct 232 ms 780 KB Output is correct
34 Correct 224 ms 780 KB Output is correct
35 Correct 230 ms 780 KB Output is correct
36 Correct 235 ms 780 KB Output is correct