Submission #584743

# Submission time Handle Problem Language Result Execution time Memory
584743 2022-06-28T01:03:30 Z penguinhacker Nautilus (BOI19_nautilus) C++17
100 / 100
157 ms 672 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=500;
int n, m, q;
bitset<mxN> mask[mxN], dp[mxN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> q;
	for (int i=0; i<n; ++i) {
		string s;
		cin >> s;
		for (int j=0; j<m; ++j)
			if (s[j]=='.')
				mask[i][j]=1, dp[i][j]=1;
	}
	string query;
	cin >> query;
	for (char c : query) {
		bitset<mxN> ndp[mxN];
		if (c=='W'||c=='?')
			for (int i=0; i<n; ++i)
				ndp[i]|=(dp[i]>>1)&mask[i];
		if (c=='E'||c=='?')
			for (int i=0; i<n; ++i)
				ndp[i]|=(dp[i]<<1)&mask[i];
		if (c=='N'||c=='?')
			for (int i=1; i<n; ++i)
				ndp[i-1]|=dp[i]&mask[i-1];
		if (c=='S'||c=='?')
			for (int i=0; i+1<n; ++i)
				ndp[i+1]|=dp[i]&mask[i+1];
		for (int i=0; i<n; ++i)
			swap(dp[i], ndp[i]);
	}
	int ans=0;
	for (int i=0; i<n; ++i)
		ans+=dp[i].count();
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 380 KB Output is correct
14 Correct 1 ms 380 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 380 KB Output is correct
14 Correct 1 ms 380 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 73 ms 664 KB Output is correct
23 Correct 82 ms 624 KB Output is correct
24 Correct 75 ms 668 KB Output is correct
25 Correct 77 ms 596 KB Output is correct
26 Correct 73 ms 656 KB Output is correct
27 Correct 112 ms 664 KB Output is correct
28 Correct 124 ms 664 KB Output is correct
29 Correct 113 ms 664 KB Output is correct
30 Correct 116 ms 668 KB Output is correct
31 Correct 106 ms 648 KB Output is correct
32 Correct 135 ms 596 KB Output is correct
33 Correct 141 ms 672 KB Output is correct
34 Correct 157 ms 668 KB Output is correct
35 Correct 138 ms 672 KB Output is correct
36 Correct 135 ms 596 KB Output is correct