Submission #496548

# Submission time Handle Problem Language Result Execution time Memory
496548 2021-12-21T13:53:56 Z Nuraly_Serikbay Nautilus (BOI19_nautilus) C++14
100 / 100
199 ms 1092 KB
#include <bits/stdc++.h>
  
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1  
 
  
using namespace std;
   
typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
   
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const int INF = 1e9 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
   
 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}
 
void pre (ll a) {
    cout << fixed << setprecision(a);
    return;
}
 
string s[505];
string a;
int r, c, m;
int ans, el;
 
void solve() {
	cin >> r >> c >> m;
	bitset<500> b[r], bad[r], re, down[r], up[r], left[r], right[r];
	for (int i = 0; i < 500; i ++) re[i] = 0;
	
	for (int i = 0; i < r; i ++) {
		cin >> s[i];
		b[i] = bad[i] = re;
		for (int j = 0; j < c; j ++) {
			b[i][j] = (s[i][j] == '.');
			bad[i][j] = (s[i][j] == '.');
		}
	}
	cin >> a;
	for (int k = 0; k < m; k ++) {
		if (a[k] == 'W') {
			for (int i = 0; i < r; i ++) {
				b[i] = (b[i] >> 1);
				b[i] = b[i] & bad[i];
			}
		}
		if (a[k] == 'E') {
			for (int i = 0; i < r; i ++) {
				b[i] = (b[i] << 1);
				b[i] = b[i] & bad[i];
			}
		}
		if (a[k] == 'N') {
			for (int i = 0; i < r - 1; i ++) {
				b[i] = b[i + 1] & bad[i];
			}
			b[r - 1] = re;
		}
		if (a[k] == 'S') {
			for (int i = r - 1; i > 0; i --) {
				b[i] = b[i - 1] & bad[i];
			}
			b[0] = re;
		}
		if (a[k] == '?') {
			up[0] = re;
			down[r - 1] = re;
			for (int i = 0; i < r; i ++) {
				if (i != 0)
					up[i] = b[i - 1];
				if (i != r - 1)
					down[i] = b[i + 1];
				left[i] = (b[i] >> 1);
				right[i] = (b[i] << 1);
			}
			for (int i = 0; i < r; i ++) {
				b[i] = (((up[i] | down[i]) | right[i]) | left[i]);
				b[i] = b[i] & bad[i];
			}
		}
	}
	for (int i = 0; i < r; i ++) {
		for (int j = 0; j < c; j ++)
			if (b[i][j]) 
				ans ++;
	}
	cout << ans;
	return;
}
 
int main() {
	Zymraq ();	
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 101 ms 1012 KB Output is correct
23 Correct 104 ms 1016 KB Output is correct
24 Correct 100 ms 972 KB Output is correct
25 Correct 114 ms 1084 KB Output is correct
26 Correct 101 ms 992 KB Output is correct
27 Correct 140 ms 972 KB Output is correct
28 Correct 147 ms 1020 KB Output is correct
29 Correct 138 ms 1092 KB Output is correct
30 Correct 153 ms 1016 KB Output is correct
31 Correct 142 ms 1012 KB Output is correct
32 Correct 162 ms 1016 KB Output is correct
33 Correct 185 ms 1008 KB Output is correct
34 Correct 199 ms 1008 KB Output is correct
35 Correct 173 ms 1016 KB Output is correct
36 Correct 176 ms 984 KB Output is correct