Submission #281976

# Submission time Handle Problem Language Result Execution time Memory
281976 2020-08-23T18:10:20 Z bigg Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 5632 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
const int MAXN = 510;

int dp[MAXN][MAXN][4], orig[MAXN][MAXN];
int r, c, m;
string s;
int main(){
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	cin >> r >> c >> m;
	for(int i = 1; i <= r; i ++){
		for(int j = 1; j <= c; j++){
			char c;
			cin >> c;
			if(c == '.') dp[i][j][1] = 1, orig[i][j] = 1;
			
		}
	}
	cin >> s;
	for(int k = 0; k < m; k++ ){
		int p = k%2;
		//printf("%d\n",p );
		for(int i = 1; i <= r; i++){
			for(int j = 1; j <= c; j++){
				dp[i][j][p] = 0;
				if(s[k] == '?')dp[i][j][p] = (dp[i-1][j][1-p] | dp[i+1][j][1-p] | dp[i][j-1][1-p] | dp[i][j+1][1-p]);
				if(s[k] == 'N') dp[i][j][p] = dp[i+1][j][1-p];
				if(s[k] == 'S') dp[i][j][p] = dp[i-1][j][1-p];
				if(s[k] == 'E') dp[i][j][p] = dp[i][j-1][1-p];
				if(s[k] == 'W') dp[i][j][p] = dp[i][j+1][1-p];
				dp[i][j][p] &= orig[i][j];
				//printf("%d ", dp[i][j][p]);
 			}
 			//printf("\n");
		}
	}
	int ans = 0;
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			//printf("%d",dp[i][j][1-m%2] );
			ans += dp[i][j][1-m%2];
		}
		//printf("\n");
	}
	cout << ans << endl;


}

Compilation message

nautilus.cpp:4: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("O3")
      | 
nautilus.cpp:5: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1024 KB Output is correct
2 Correct 4 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 4 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1024 KB Output is correct
2 Correct 4 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 4 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 896 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
13 Correct 5 ms 1152 KB Output is correct
14 Correct 7 ms 1024 KB Output is correct
15 Correct 5 ms 1024 KB Output is correct
16 Correct 6 ms 896 KB Output is correct
17 Correct 5 ms 1152 KB Output is correct
18 Correct 5 ms 1024 KB Output is correct
19 Correct 4 ms 1024 KB Output is correct
20 Correct 4 ms 1024 KB Output is correct
21 Correct 5 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1024 KB Output is correct
2 Correct 4 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 4 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 896 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
13 Correct 5 ms 1152 KB Output is correct
14 Correct 7 ms 1024 KB Output is correct
15 Correct 5 ms 1024 KB Output is correct
16 Correct 6 ms 896 KB Output is correct
17 Correct 5 ms 1152 KB Output is correct
18 Correct 5 ms 1024 KB Output is correct
19 Correct 4 ms 1024 KB Output is correct
20 Correct 4 ms 1024 KB Output is correct
21 Correct 5 ms 896 KB Output is correct
22 Execution timed out 1085 ms 5632 KB Time limit exceeded
23 Halted 0 ms 0 KB -