Submission #256237

# Submission time Handle Problem Language Result Execution time Memory
256237 2020-08-02T11:50:19 Z Blagojce Nautilus (BOI19_nautilus) C++11
100 / 100
251 ms 768 KB
#include <bits/stdc++.h> 
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
#include <time.h>
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
 
const int i_inf = 1e4;
const ll inf = 1e17;
const ll mod = 1000000007;
const ld eps = 1e-13;
const ld pi  = 3.14159265359;
 
mt19937 _rand(time(NULL));
clock_t timer = clock();
const int mxn = 200005;

int n, m, k;
 
bitset<500> dp[500];
bitset<500> cop[500];
bitset<500> mapa[500];
bitset<500> rem;
bitset<500> emp;
void solve(){
	cin >> n >> m >> k;
	fr(i, 0, m) rem[i] = 1;
	fr(i, 0, n){
		fr(j, 0, m){
			char c;
			cin >> c;
			if(c == '.') dp[i][j] = 1;
			if(c == '.') mapa[i][j] = 1;
		}
	}

	string s;
	cin >> s;

	fr(i, 0, k){
		if(s[i] == 'W'){
			fr(j, 0, n){
				dp[j] >>= 1;
			}
		}
		else if(s[i] == 'E'){
			fr(j, 0, n){
				dp[j] <<= 1;
			}
		}
		else if(s[i] == 'N'){
			fr(j, 0, n-1){
				dp[j] = dp[j+1];
			}
			dp[n-1].reset();
		}
		else if(s[i] == 'S'){
			for(int j = n-1; j > 0; j --){
				dp[j] = dp[j-1];
			}
			dp[0].reset();
		}
		else{
			fr(j, 0, n){
				if(j == 0) cop[j] = dp[j+1];
				else if(j == n-1) cop[j] = dp[j-1];
				else cop[j] = dp[j-1]|dp[j+1];
			}
			fr(j, 0, n){
				dp[j] = cop[j]|(dp[j]>>1)|(dp[j]<<1);
			}
		}
		fr(j, 0, n) dp[j] = dp[j]&mapa[j];
		
	}
	int ans = 0;
	fr(i, 0, n) ans += dp[i].count();
	cout<<ans<<endl;
	
	
	
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 111 ms 640 KB Output is correct
23 Correct 112 ms 640 KB Output is correct
24 Correct 110 ms 768 KB Output is correct
25 Correct 110 ms 748 KB Output is correct
26 Correct 108 ms 760 KB Output is correct
27 Correct 182 ms 740 KB Output is correct
28 Correct 189 ms 640 KB Output is correct
29 Correct 185 ms 640 KB Output is correct
30 Correct 182 ms 640 KB Output is correct
31 Correct 183 ms 724 KB Output is correct
32 Correct 244 ms 640 KB Output is correct
33 Correct 249 ms 640 KB Output is correct
34 Correct 240 ms 640 KB Output is correct
35 Correct 238 ms 740 KB Output is correct
36 Correct 251 ms 724 KB Output is correct