# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
491844 |
2021-12-04T18:11:43 Z |
codr0 |
Nautilus (BOI19_nautilus) |
C++14 |
|
185 ms |
844 KB |
// Code by Parsa Eslami
#include <bits/stdc++.h>
#define int long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define S second
#define F first
#define pb push_back
#define SZ(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define err(x) cerr<<#x<<" : "<<x<<'\n'
#define MOD(x) if(x>=M) x-=M; if(x<0) x+=M;
using namespace std;
const int N=500+3;
bitset<N> ocean[N];
bitset<N> B1[N];
bitset<N> BW[N];
bitset<N> BE[N];
bitset<N> BN[N];
bitset<N> BS[N];
int r,c;
void Do(int x0,int y0){
if(x0==0){
if(y0==1){
FOR(i,1,r) BE[i]=B1[i]<<1;
}else{
FOR(i,1,r) BW[i]=B1[i]>>1;
}
}else{
if(x0==1){
BS[1].reset();
FOR(i,2,r) BS[i]=B1[i-1];
}else{
FOR(i,1,r-1) BN[i]=B1[i+1];
BN[r].reset();
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int m;
cin>>r>>c>>m;
FOR(i,1,r){
FOR(j,1,c) {
char x0;
cin>>x0;
if(x0!='#') ocean[i][j]=1;
}
}
string S; cin>>S;
FOR(i,1,r) FOR(j,1,c) B1[i][j]=ocean[i][j];
FOR(i,0,m-1){
if(S[i]=='?'){
Do(1,0);
Do(0,1);
Do(-1,0);
Do(0,-1);
FOR(i0,1,r) B1[i0]=((BS[i0]|BW[i0]|BE[i0]|BN[i0])&ocean[i0]);
}else if(S[i]=='W') {
Do(0,-1);
FOR(i0,1,r) B1[i0]=((BW[i0])&ocean[i0]);
}
else if(S[i]=='E'){
Do(0,+1);
FOR(i0,1,r) B1[i0]=((BE[i0])&ocean[i0]);
}
else if(S[i]=='N'){
Do(-1,0);
FOR(i0,1,r) B1[i0]=((BN[i0])&ocean[i0]);
}
else if(S[i]=='S'){
Do(+1,0);
FOR(i0,1,r) B1[i0]=((BS[i0])&ocean[i0]);
}
}
int ans=0;
FOR(i,1,r) FOR(j,1,c) ans+=B1[i][j];
cout<<ans<<'\n';
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 |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
2 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 |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
1 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 |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
2 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 |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
86 ms |
764 KB |
Output is correct |
23 |
Correct |
93 ms |
760 KB |
Output is correct |
24 |
Correct |
97 ms |
756 KB |
Output is correct |
25 |
Correct |
84 ms |
748 KB |
Output is correct |
26 |
Correct |
82 ms |
732 KB |
Output is correct |
27 |
Correct |
136 ms |
752 KB |
Output is correct |
28 |
Correct |
144 ms |
752 KB |
Output is correct |
29 |
Correct |
131 ms |
844 KB |
Output is correct |
30 |
Correct |
137 ms |
756 KB |
Output is correct |
31 |
Correct |
152 ms |
728 KB |
Output is correct |
32 |
Correct |
167 ms |
840 KB |
Output is correct |
33 |
Correct |
168 ms |
744 KB |
Output is correct |
34 |
Correct |
177 ms |
752 KB |
Output is correct |
35 |
Correct |
172 ms |
760 KB |
Output is correct |
36 |
Correct |
185 ms |
720 KB |
Output is correct |