Submission #891588

# Submission time Handle Problem Language Result Execution time Memory
891588 2023-12-23T09:29:49 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
154 ms 1364 KB
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;

#define all(x) x.begin(),x.end()
#define pb push_back
#define ent "\n"

#define int long long

const int maxn = (int)1e6 + 13;
const ll inf = (long long)1e18 + 20;
const int mod = (int)1e9 + 7;

int n,m,k;
char a[501][501];

void solve(){
	cin >> n >> m >>k;
	bitset<500>ok[n],ans[n],s[n],d[n],f[n],g[n],r[n], cl;
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			cin >> a[i][j];
			if(a[i][j] == '.'){
				ok[i][j] = 1;
				ans[i][j] = 1;
			}
			else{
				ok[i][j] = 0;
				ans[i][j] = 0;
			}
		}
	}
	string S;cin >> S;
	for(int i = 0 ; i < k ; i ++){
		if(S[i] == 'E'){
			for(int j = 0 ; j < n ; j ++){
				ans[j] <<= 1;
				ans[j] &= ok[j];
			}
		}
		if(S[i ] == 'W'){
			for(int j = 0 ; j < n ; j ++){
				ans[j] >>= 1;
				ans[j] &= ok[j];
			}
		}
		if(S[i] == 'N'){
			for(int j = 0 ; j < n - 1 ; j ++){
				ans[j] = ans[j + 1] & ok[j];
			}
			for(int j = 0 ; j < m ; j ++){
				ans[n - 1][j] = 0;
			}
		}
		if(S[i] == 'S'){
			for(int j = n - 1 ; j > 0 ; j --){
				ans[j] = ans[j - 1] & ok[j];
			}
			for(int j = 0 ; j < m ; j ++){
				ans[0][j] = 0;
			}
		}
		if(S[i] == '?'){
			for(int j = 0 ; j < n ; j ++){
				s[j] = ans[j];
				d[j] = ans[j];
				f[j] = ans[j];
				g[j] = ans[j];
			}
			for(int j = 0 ; j < n ; j ++){
				s[j] >>= 1;
			}
			for(int j = 0 ; j < n ; j ++){
				d[j] <<= 1;
			}
			for(int j = 0 ; j < n - 1 ; j ++){
				f[j] = ans[j + 1];
			}
			for(int j = n - 1 ; j > 0 ; j --){
				g[j] = ans[j - 1];
			}
			for (int i = 0; i < m; ++ i) f[n - 1][i] = 0,g[0][i] = 0;
			for(int j = 0 ; j < n ; j ++){
				r[j] = (s[j] | d[j] | f[j] | g[j]);
				r[j] &= ok[j];
				ans[j] = r[j];
			}
		}
	}
	int res = 0;
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < m ; j ++){
			res += ans[i][j];
		}
	}
	cout << res;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t --){
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 1 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 1 ms 472 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 476 KB Output is correct
14 Correct 1 ms 560 KB Output is correct
15 Correct 1 ms 564 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 1 ms 472 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 476 KB Output is correct
14 Correct 1 ms 560 KB Output is correct
15 Correct 1 ms 564 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 67 ms 1116 KB Output is correct
23 Correct 69 ms 1164 KB Output is correct
24 Correct 66 ms 1112 KB Output is correct
25 Correct 65 ms 1156 KB Output is correct
26 Correct 64 ms 1160 KB Output is correct
27 Correct 114 ms 1160 KB Output is correct
28 Correct 116 ms 1112 KB Output is correct
29 Correct 116 ms 1112 KB Output is correct
30 Correct 116 ms 1116 KB Output is correct
31 Correct 114 ms 1160 KB Output is correct
32 Correct 152 ms 1116 KB Output is correct
33 Correct 154 ms 1116 KB Output is correct
34 Correct 154 ms 1364 KB Output is correct
35 Correct 154 ms 1156 KB Output is correct
36 Correct 153 ms 1156 KB Output is correct