Submission #313741

# Submission time Handle Problem Language Result Execution time Memory
313741 2020-10-16T21:44:17 Z sofapuden Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 3328 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 505;

int G[maxn][maxn], dp[maxn][maxn][2], n, m, Q;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> Q;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			char c; cin >> c;
			G[i][j] = (c == '.');
			dp[i][j][0] = G[i][j];
		}
	}
	string s; cin >> s;
	for(int i = 0; i < Q; ++i){
		for(int j = 0; j < n; ++j){
			for(int k = 0; k < m; ++k){
				int cur = 0;
				if(s[i] == '?'){
					if(j)cur |= dp[j-1][k][i&1];
					if(j!=n-1)cur |= dp[j+1][k][i&1];
					if(k)cur |= dp[j][k-1][i&1];
					if(k!=m-1)cur |= dp[j][k+1][i&1];
				}
				if(s[i] == 'N' && j != n-1)cur|=dp[j+1][k][i&1];
				if(s[i] == 'E' && k)cur|=dp[j][k-1][i&1];
				if(s[i] == 'S' && j)cur|=dp[j-1][k][i&1];
				if(s[i] == 'W' && k != m-1)cur|=dp[j][k+1][i&1];
				dp[j][k][(i+1)&1] = cur&G[j][k];
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			ans+=dp[i][j][Q&1];
		}
	}
	cout << ans << "\n";
}
			
					
	
# Verdict Execution time Memory Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 5 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 5 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 4 ms 896 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 4 ms 896 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 4 ms 896 KB Output is correct
14 Correct 4 ms 896 KB Output is correct
15 Correct 4 ms 896 KB Output is correct
16 Correct 4 ms 896 KB Output is correct
17 Correct 4 ms 896 KB Output is correct
18 Correct 4 ms 896 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 4 ms 896 KB Output is correct
21 Correct 4 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 5 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 4 ms 896 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 4 ms 896 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 4 ms 896 KB Output is correct
14 Correct 4 ms 896 KB Output is correct
15 Correct 4 ms 896 KB Output is correct
16 Correct 4 ms 896 KB Output is correct
17 Correct 4 ms 896 KB Output is correct
18 Correct 4 ms 896 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 4 ms 896 KB Output is correct
21 Correct 4 ms 896 KB Output is correct
22 Execution timed out 1098 ms 3328 KB Time limit exceeded
23 Halted 0 ms 0 KB -