Submission #584785

# Submission time Handle Problem Language Result Execution time Memory
584785 2022-06-28T03:19:44 Z penguinhacker Nautilus (BOI19_nautilus) C++17
100 / 100
85 ms 668 KB
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")

#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 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 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 356 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 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 364 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 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 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 356 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 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 364 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 51 ms 596 KB Output is correct
23 Correct 49 ms 668 KB Output is correct
24 Correct 50 ms 620 KB Output is correct
25 Correct 49 ms 668 KB Output is correct
26 Correct 51 ms 652 KB Output is correct
27 Correct 68 ms 664 KB Output is correct
28 Correct 68 ms 664 KB Output is correct
29 Correct 69 ms 596 KB Output is correct
30 Correct 68 ms 668 KB Output is correct
31 Correct 69 ms 664 KB Output is correct
32 Correct 84 ms 668 KB Output is correct
33 Correct 84 ms 664 KB Output is correct
34 Correct 84 ms 596 KB Output is correct
35 Correct 84 ms 664 KB Output is correct
36 Correct 85 ms 656 KB Output is correct