답안 #125496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125496 2019-07-05T13:39:35 Z mechfrog88 Nautilus (BOI19_nautilus) C++14
100 / 100
271 ms 157568 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r,c,m;
	cin >> r >> c >> m;
	vector <string> grid(r);
	for (int z=0;z<r;z++){
		cin >> grid[z];
	}
	string signal;
	cin >> signal;
	bitset<500> dp[m+1][r];
	bitset<500> g[r];
	for (int j=0;j<r;j++){
		for (int k=0;k<c;k++){
			if (grid[j][k] == '#') {g[j][k] = 0; dp[0][j][k] = 0;}
			else {g[j][k] = 1 ; dp[0][j][k] = 1;}
		}
	}
	for (int i=1;i<=m;i++){
		char now = signal[i-1];
		for (int j=0;j<r;j++){
			if (now == 'W')	{
				dp[i][j] = dp[i-1][j] >> 1 & g[j];
			}
			if (now == 'E')	{
				dp[i][j] = dp[i-1][j] << 1 & g[j];
			}
			if (now == 'S' && j > 0){
				dp[i][j] = dp[i-1][j-1] & g[j];
			}
			if (now == 'N' && j < r-1){
				dp[i][j] = dp[i-1][j+1] & g[j];
			}
			if (now == '?'){
				if (j > 0) dp[i][j-1] |= (dp[i-1][j] | dp[i][j-1]) & g[j-1];
				if (j < r-1) dp[i][j+1] |= (dp[i-1][j] | dp[i][j+1]) & g[j+1];
				dp[i][j] |= (dp[i-1][j]<< 1) | (dp[i-1][j] >> 1) & g[j];
				dp[i][j] &= g[j];
			}
		}
	}
	ll ans = 0;
	for (int z=0;z<r;z++){
		for (int x=0;x<c;x++){
			if (dp[m][z][x]) ans++;
		}
	}
	cout << ans << endl;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:53:54: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     dp[i][j] |= (dp[i-1][j]<< 1) | (dp[i-1][j] >> 1) & g[j];
                                    ~~~~~~~~~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 3 ms 1016 KB Output is correct
11 Correct 3 ms 1016 KB Output is correct
12 Correct 3 ms 1016 KB Output is correct
13 Correct 3 ms 1016 KB Output is correct
14 Correct 3 ms 1016 KB Output is correct
15 Correct 3 ms 1016 KB Output is correct
16 Correct 3 ms 1016 KB Output is correct
17 Correct 3 ms 1016 KB Output is correct
18 Correct 3 ms 1016 KB Output is correct
19 Correct 3 ms 1016 KB Output is correct
20 Correct 4 ms 1016 KB Output is correct
21 Correct 4 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 3 ms 1016 KB Output is correct
11 Correct 3 ms 1016 KB Output is correct
12 Correct 3 ms 1016 KB Output is correct
13 Correct 3 ms 1016 KB Output is correct
14 Correct 3 ms 1016 KB Output is correct
15 Correct 3 ms 1016 KB Output is correct
16 Correct 3 ms 1016 KB Output is correct
17 Correct 3 ms 1016 KB Output is correct
18 Correct 3 ms 1016 KB Output is correct
19 Correct 3 ms 1016 KB Output is correct
20 Correct 4 ms 1016 KB Output is correct
21 Correct 4 ms 1016 KB Output is correct
22 Correct 216 ms 157452 KB Output is correct
23 Correct 271 ms 157524 KB Output is correct
24 Correct 242 ms 157488 KB Output is correct
25 Correct 230 ms 157560 KB Output is correct
26 Correct 222 ms 157520 KB Output is correct
27 Correct 244 ms 157408 KB Output is correct
28 Correct 246 ms 157500 KB Output is correct
29 Correct 247 ms 157432 KB Output is correct
30 Correct 245 ms 157544 KB Output is correct
31 Correct 250 ms 157564 KB Output is correct
32 Correct 265 ms 157560 KB Output is correct
33 Correct 269 ms 157432 KB Output is correct
34 Correct 269 ms 157568 KB Output is correct
35 Correct 268 ms 157532 KB Output is correct
36 Correct 269 ms 157536 KB Output is correct