Submission #926062

# Submission time Handle Problem Language Result Execution time Memory
926062 2024-02-12T14:08:25 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
163 ms 1132 KB
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(),a.end()
#define pb push_back
#define vt vector
#define endl '\n'
typedef long long ll;

const ll mod=1e9+7;
const ll inf=mod;
const int N=5e6+4;

int n,m,k;
char c[600][600];
bitset<600> dp[2][600],cons[600];

void solve(){
	cin>>n>>m>>k;
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=m; ++j){
			cin>>c[i][j];
			if(c[i][j]!='#') dp[0][i][j]=1;
			dp[0][0][j]=0;
			dp[0][n+1][j]=0;
		}
		dp[0][i][0]=dp[0][i][m+1]=0;
		cons[i]=dp[0][i];
		dp[1][i]=dp[0][i];
	}
	string s;
	cin>>s;
	s='#'+s;
	for(int x=1; x<=k; ++x){
		for(int i=1; i<=n; ++i){
			if(s[x]=='N') dp[1][i]&=dp[0][i+1];
			if(s[x]=='S') dp[1][i]&=dp[0][i-1];
			if(s[x]=='W') dp[1][i]&=(dp[0][i]>>1);
			if(s[x]=='E') dp[1][i]&=(dp[0][i]<<1);
			if(s[x]=='?') dp[1][i]&=((dp[0][i]>>1)|(dp[0][i]<<1)|dp[0][i+1]|dp[0][i-1]);
		}
		for(int i=1; i<=n; ++i){
			dp[0][i]=dp[1][i];
			dp[1][i]=cons[i];
		}
	}
	int ans=0;
	for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j){
		ans+=dp[0][i][j];
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int tt=1;
//	cin>>tt;
	while(tt--) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 476 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 476 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 74 ms 1116 KB Output is correct
23 Correct 75 ms 1116 KB Output is correct
24 Correct 75 ms 1112 KB Output is correct
25 Correct 73 ms 1112 KB Output is correct
26 Correct 74 ms 1112 KB Output is correct
27 Correct 112 ms 1112 KB Output is correct
28 Correct 123 ms 1112 KB Output is correct
29 Correct 113 ms 1116 KB Output is correct
30 Correct 115 ms 1124 KB Output is correct
31 Correct 126 ms 1124 KB Output is correct
32 Correct 142 ms 1112 KB Output is correct
33 Correct 143 ms 1124 KB Output is correct
34 Correct 163 ms 1132 KB Output is correct
35 Correct 142 ms 1116 KB Output is correct
36 Correct 142 ms 1116 KB Output is correct