# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1106739 |
2024-10-31T02:28:16 Z |
modwwe |
Nautilus (BOI19_nautilus) |
C++17 |
|
126 ms |
158896 KB |
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define rep2(i,a,b,c) for (int i=a;i<=b;i+=c)
#define rev(i,a,b) for (int i=a;i>=b;i--)
#define rev2(i,a,b,c) for (int i=a;i>=b;i-=c)
#define ii pair<ll,ll>
#define bit(i,j) ((i>>j)&1)
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define ll long long
#define F first
#define S second
#define sz(a) (ll)(a.size())
#define on(n) __builtin_popcountll(n)
#define ld long double
#define __log2(x) 31-__builtin_clz(x)
#define Mask(x) (1LL<<x)
#define ALL(v) v.begin(),v.end()
const int N=5e3+5;
const int mod=1e9+7;
const int INF=1e9;
const int MAX=1e9;
int n,m,k;
string s;
char a[505][505];
bitset<505> dp[N][505],mask[505];
void solution(){
cin >> n >> m >> k;
rep(i,1,n) rep(j,1,m) cin >> a[i][j];
cin >> s;
s=' '+s;
rep(i,1,n) rep(j,1,m)
if (a[i][j]=='.') dp[0][i].set(j),mask[i].set(j);
rep(i,1,k)
rep(row,1,n){
if (s[i]=='N'||s[i]=='?') dp[i][row]|=dp[i-1][row+1];
if (s[i]=='S'||s[i]=='?') dp[i][row]|=dp[i-1][row-1];
if (s[i]=='E'||s[i]=='?') dp[i][row]|=(dp[i-1][row]<<1);
if (s[i]=='W'||s[i]=='?') dp[i][row]|=(dp[i-1][row]>>1);
dp[i][row]&=mask[row];
}
int res=0;
rep(row,1,n) res+=dp[k][row].count();
cout << res;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test=1;
//cin >> test;
while(test--)
solution();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
2 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
2 ms |
4432 KB |
Output is correct |
11 |
Correct |
2 ms |
4432 KB |
Output is correct |
12 |
Correct |
2 ms |
4432 KB |
Output is correct |
13 |
Correct |
2 ms |
4432 KB |
Output is correct |
14 |
Correct |
2 ms |
4432 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4432 KB |
Output is correct |
17 |
Correct |
2 ms |
4600 KB |
Output is correct |
18 |
Correct |
2 ms |
4432 KB |
Output is correct |
19 |
Correct |
2 ms |
4432 KB |
Output is correct |
20 |
Correct |
2 ms |
4432 KB |
Output is correct |
21 |
Correct |
2 ms |
4688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
2 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
2 ms |
4432 KB |
Output is correct |
11 |
Correct |
2 ms |
4432 KB |
Output is correct |
12 |
Correct |
2 ms |
4432 KB |
Output is correct |
13 |
Correct |
2 ms |
4432 KB |
Output is correct |
14 |
Correct |
2 ms |
4432 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4432 KB |
Output is correct |
17 |
Correct |
2 ms |
4600 KB |
Output is correct |
18 |
Correct |
2 ms |
4432 KB |
Output is correct |
19 |
Correct |
2 ms |
4432 KB |
Output is correct |
20 |
Correct |
2 ms |
4432 KB |
Output is correct |
21 |
Correct |
2 ms |
4688 KB |
Output is correct |
22 |
Correct |
79 ms |
158896 KB |
Output is correct |
23 |
Correct |
79 ms |
158660 KB |
Output is correct |
24 |
Correct |
78 ms |
158764 KB |
Output is correct |
25 |
Correct |
76 ms |
158808 KB |
Output is correct |
26 |
Correct |
77 ms |
158792 KB |
Output is correct |
27 |
Correct |
102 ms |
158688 KB |
Output is correct |
28 |
Correct |
104 ms |
158664 KB |
Output is correct |
29 |
Correct |
105 ms |
158732 KB |
Output is correct |
30 |
Correct |
104 ms |
158656 KB |
Output is correct |
31 |
Correct |
102 ms |
158824 KB |
Output is correct |
32 |
Correct |
125 ms |
158896 KB |
Output is correct |
33 |
Correct |
126 ms |
158792 KB |
Output is correct |
34 |
Correct |
125 ms |
158792 KB |
Output is correct |
35 |
Correct |
125 ms |
158792 KB |
Output is correct |
36 |
Correct |
124 ms |
158792 KB |
Output is correct |