Submission #672663

# Submission time Handle Problem Language Result Execution time Memory
672663 2022-12-17T11:04:02 Z CSQ31 Nautilus (BOI19_nautilus) C++17
100 / 100
49 ms 640 KB
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
bitset<500>b[500],a[501],c[500];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char c;
			cin>>c;
			if(c=='.'){
				b[i][j] = a[i][j] = 1;
			}
		}
		
	}
	string s;
	cin>>s;
	for(int x=0;x<k;x++){
		if(s[x] == 'E'){
			for(int i=0;i<n;i++){
				a[i]<<=1;
				a[i]&=b[i];
			}	
		}
		else if(s[x] == 'W'){
			for(int i=0;i<n;i++){
				a[i]>>=1;
				a[i]&=b[i];
			}	
		}
		else if(s[x] == 'S'){
			for(int i=n-1;i>0;i--)a[i] = a[i-1] & b[i];
			a[0] &= a[500];
			
		}else if(s[x] == 'N'){
			for(int i=0;i+1<n;i++)a[i] = a[i+1] & b[i];
			a[n-1] &= a[500];
		}else{
			for(int i=0;i<n;i++){
				c[i] = (a[i]>>1) | (a[i]<<1);
				if(i)c[i] |= a[i-1];
				if(i+1<n)c[i] |= a[i+1];
				c[i] &= b[i];
			}
			for(int i=0;i<n;i++)a[i] = c[i];
		}
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)ans+=a[i][j];
	}
	cout<<ans;
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 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 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 308 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 312 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 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 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 308 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 312 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 29 ms 600 KB Output is correct
23 Correct 30 ms 616 KB Output is correct
24 Correct 29 ms 596 KB Output is correct
25 Correct 31 ms 596 KB Output is correct
26 Correct 34 ms 596 KB Output is correct
27 Correct 39 ms 640 KB Output is correct
28 Correct 41 ms 596 KB Output is correct
29 Correct 42 ms 596 KB Output is correct
30 Correct 40 ms 596 KB Output is correct
31 Correct 38 ms 632 KB Output is correct
32 Correct 47 ms 640 KB Output is correct
33 Correct 49 ms 608 KB Output is correct
34 Correct 48 ms 596 KB Output is correct
35 Correct 47 ms 596 KB Output is correct
36 Correct 45 ms 612 KB Output is correct