Submission #659127

# Submission time Handle Problem Language Result Execution time Memory
659127 2022-11-16T16:38:50 Z beaconmc Nautilus (BOI19_nautilus) C++14
100 / 100
234 ms 460 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")

#pragma GCC target ("avx2")
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
//#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

bitset<512>  grid[501];

char ins[5001];

bitset<512> dp[2][512];

ll r,c,m;

bool valid(ll a, ll b){
	if (0<=a && a<r && 0<=b && b<c) return true;
	return false;
}

int main(){

	cin >> r >> c >> m;
	FOR(i,0,r){
		string temp; cin >> temp;
		FOR(j,0,c){
			if (temp[j]=='.') grid[i][j] = 1;
			else grid[i][j] = 0;
		}
	}
	string temp; cin >> temp;
	FOR(i,0,m) ins[i] = temp[i];

	FOR(i,0,r){
		FOR(j,0,c){
			dp[0][i][j] = grid[i][j];

		}
	}





	FOR(k,1,m+1){


		if (ins[k-1] == 'W' || ins[k-1] == '?'){
			FOR(i,0,r) dp[1][i] |= dp[0][i]>>1;
		}
		if (ins[k-1] == 'E' || ins[k-1] == '?'){
			FOR(i,0,r) dp[1][i] |= dp[0][i]<<1;
		}
		if (ins[k-1] == 'S' || ins[k-1] == '?'){
			FOR(i,1,r) dp[1][i] |= dp[0][i-1];
		}
		if (ins[k-1] == 'N' || ins[k-1] == '?'){
			FOR(i,0,r) dp[1][i] |= dp[0][i+1];
		}

		FOR(i,0,r) dp[1][i] &= grid[i];
		FOR(i,0,r) dp[0][i] = 0;
		FOR(i,0,r) dp[0][i] = dp[1][i];
		FOR(i,0,r) dp[1][i] = 0;
	}

	ll ans = 0;
	FOR(i,0,r){
		FOR(j,0,c){
			if (dp[0][i][j] == 1) ans++;
		}
	}
	cout << ans << endl;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 2 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 2 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 168 ms 392 KB Output is correct
23 Correct 173 ms 404 KB Output is correct
24 Correct 175 ms 340 KB Output is correct
25 Correct 166 ms 388 KB Output is correct
26 Correct 170 ms 340 KB Output is correct
27 Correct 187 ms 392 KB Output is correct
28 Correct 207 ms 388 KB Output is correct
29 Correct 193 ms 392 KB Output is correct
30 Correct 190 ms 460 KB Output is correct
31 Correct 199 ms 392 KB Output is correct
32 Correct 212 ms 388 KB Output is correct
33 Correct 210 ms 340 KB Output is correct
34 Correct 218 ms 396 KB Output is correct
35 Correct 234 ms 340 KB Output is correct
36 Correct 227 ms 388 KB Output is correct