# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
840951 |
2023-09-01T02:08:27 Z |
hafo |
Nautilus (BOI19_nautilus) |
C++14 |
|
169 ms |
159636 KB |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define Size(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}
const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 500 + 7;
const ll oo = 1e18 + 69;
int n, m, k;
string st;
char a[maxn][maxn];
bitset<maxn> dp[5007][maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(TASK".inp", "r", stdin);
//freopen(TASK".out", "w", stdout);
cin>>n>>m>>k;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin>>a[i][j];
dp[0][i][j] = (a[i][j] == '.');
}
}
cin>>st;
st = ' ' + st;
for(int i = 1; i <= k; i++) {
for(int x = 1; x <= n; x++) {
if(st[i] == 'N' || st[i] == '?') {
dp[i][x] |= dp[i - 1][x + 1];
}
if(st[i] == 'S' || st[i] == '?') {
dp[i][x] |= dp[i - 1][x - 1];
}
if(st[i] == 'W' || st[i] == '?') {
dp[i][x] |= (dp[i - 1][x] >> 1);
}
if(st[i] == 'E' || st[i] == '?') {
dp[i][x] |= (dp[i - 1][x] << 1);
}
dp[i][x] &= dp[0][x];
}
}
int ans = 0;
for(int i = 1; i <= n; i++) ans += dp[k][i].count();
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1400 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1400 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1368 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1408 KB |
Output is correct |
12 |
Correct |
1 ms |
1360 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
1 ms |
1364 KB |
Output is correct |
15 |
Correct |
1 ms |
1364 KB |
Output is correct |
16 |
Correct |
1 ms |
1364 KB |
Output is correct |
17 |
Correct |
1 ms |
1364 KB |
Output is correct |
18 |
Correct |
1 ms |
1360 KB |
Output is correct |
19 |
Correct |
1 ms |
1364 KB |
Output is correct |
20 |
Correct |
1 ms |
1376 KB |
Output is correct |
21 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
1 ms |
1400 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1368 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1408 KB |
Output is correct |
12 |
Correct |
1 ms |
1360 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
1 ms |
1364 KB |
Output is correct |
15 |
Correct |
1 ms |
1364 KB |
Output is correct |
16 |
Correct |
1 ms |
1364 KB |
Output is correct |
17 |
Correct |
1 ms |
1364 KB |
Output is correct |
18 |
Correct |
1 ms |
1360 KB |
Output is correct |
19 |
Correct |
1 ms |
1364 KB |
Output is correct |
20 |
Correct |
1 ms |
1376 KB |
Output is correct |
21 |
Correct |
1 ms |
1364 KB |
Output is correct |
22 |
Correct |
107 ms |
159544 KB |
Output is correct |
23 |
Correct |
106 ms |
159552 KB |
Output is correct |
24 |
Correct |
106 ms |
159560 KB |
Output is correct |
25 |
Correct |
107 ms |
159488 KB |
Output is correct |
26 |
Correct |
108 ms |
159564 KB |
Output is correct |
27 |
Correct |
138 ms |
159492 KB |
Output is correct |
28 |
Correct |
134 ms |
159588 KB |
Output is correct |
29 |
Correct |
135 ms |
159488 KB |
Output is correct |
30 |
Correct |
156 ms |
159564 KB |
Output is correct |
31 |
Correct |
138 ms |
159636 KB |
Output is correct |
32 |
Correct |
160 ms |
159592 KB |
Output is correct |
33 |
Correct |
158 ms |
159532 KB |
Output is correct |
34 |
Correct |
169 ms |
159576 KB |
Output is correct |
35 |
Correct |
161 ms |
159544 KB |
Output is correct |
36 |
Correct |
159 ms |
159588 KB |
Output is correct |