# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
667175 |
2022-11-30T16:03:36 Z |
Kahou |
Nautilus (BOI19_nautilus) |
C++14 |
|
291 ms |
156744 KB |
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 505, M = 5005;
int n, m, k;
string s;
bitset<N*N> grid;
bitset<N*N> dp[M];
char dr[4] = {'N','E','S','W'};
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int f(int x, int y) {
return x*N + y;
}
void solve() {
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
for (int j= 1; j <= m; j++) {
char c;
cin >> c;
grid[f(i, j)] = dp[0][f(i,j)] = (c == '.');
}
}
cin >> s;
for (int p = 1; p <= k; p++) {
for (int i = 0; i < 4; i++) {
if (s[p-1] == '?' || s[p-1] == dr[i]) {
int off = f(dx[i], dy[i]);
if (off >= 0) dp[p] = dp[p]|(dp[p-1]<<off);
else dp[p] = dp[p]|(dp[p-1]>>(-off));
}
}
dp[p] = dp[p] & grid;
}
cout << dp[k].count() << endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3412 KB |
Output is correct |
2 |
Correct |
4 ms |
3540 KB |
Output is correct |
3 |
Correct |
4 ms |
3540 KB |
Output is correct |
4 |
Correct |
4 ms |
3460 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
4 ms |
3540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3412 KB |
Output is correct |
2 |
Correct |
4 ms |
3540 KB |
Output is correct |
3 |
Correct |
4 ms |
3540 KB |
Output is correct |
4 |
Correct |
4 ms |
3460 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
4 ms |
3540 KB |
Output is correct |
7 |
Correct |
4 ms |
3412 KB |
Output is correct |
8 |
Correct |
5 ms |
3540 KB |
Output is correct |
9 |
Correct |
5 ms |
3412 KB |
Output is correct |
10 |
Correct |
5 ms |
3540 KB |
Output is correct |
11 |
Correct |
5 ms |
3452 KB |
Output is correct |
12 |
Correct |
6 ms |
3540 KB |
Output is correct |
13 |
Correct |
6 ms |
3412 KB |
Output is correct |
14 |
Correct |
6 ms |
3484 KB |
Output is correct |
15 |
Correct |
6 ms |
3464 KB |
Output is correct |
16 |
Correct |
6 ms |
3492 KB |
Output is correct |
17 |
Correct |
6 ms |
3456 KB |
Output is correct |
18 |
Correct |
7 ms |
3412 KB |
Output is correct |
19 |
Correct |
7 ms |
3540 KB |
Output is correct |
20 |
Correct |
6 ms |
3468 KB |
Output is correct |
21 |
Correct |
6 ms |
3540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3412 KB |
Output is correct |
2 |
Correct |
4 ms |
3540 KB |
Output is correct |
3 |
Correct |
4 ms |
3540 KB |
Output is correct |
4 |
Correct |
4 ms |
3460 KB |
Output is correct |
5 |
Correct |
4 ms |
3412 KB |
Output is correct |
6 |
Correct |
4 ms |
3540 KB |
Output is correct |
7 |
Correct |
4 ms |
3412 KB |
Output is correct |
8 |
Correct |
5 ms |
3540 KB |
Output is correct |
9 |
Correct |
5 ms |
3412 KB |
Output is correct |
10 |
Correct |
5 ms |
3540 KB |
Output is correct |
11 |
Correct |
5 ms |
3452 KB |
Output is correct |
12 |
Correct |
6 ms |
3540 KB |
Output is correct |
13 |
Correct |
6 ms |
3412 KB |
Output is correct |
14 |
Correct |
6 ms |
3484 KB |
Output is correct |
15 |
Correct |
6 ms |
3464 KB |
Output is correct |
16 |
Correct |
6 ms |
3492 KB |
Output is correct |
17 |
Correct |
6 ms |
3456 KB |
Output is correct |
18 |
Correct |
7 ms |
3412 KB |
Output is correct |
19 |
Correct |
7 ms |
3540 KB |
Output is correct |
20 |
Correct |
6 ms |
3468 KB |
Output is correct |
21 |
Correct |
6 ms |
3540 KB |
Output is correct |
22 |
Correct |
181 ms |
156664 KB |
Output is correct |
23 |
Correct |
192 ms |
156632 KB |
Output is correct |
24 |
Correct |
223 ms |
156668 KB |
Output is correct |
25 |
Correct |
181 ms |
156616 KB |
Output is correct |
26 |
Correct |
181 ms |
156592 KB |
Output is correct |
27 |
Correct |
232 ms |
156624 KB |
Output is correct |
28 |
Correct |
236 ms |
156576 KB |
Output is correct |
29 |
Correct |
265 ms |
156640 KB |
Output is correct |
30 |
Correct |
228 ms |
156640 KB |
Output is correct |
31 |
Correct |
236 ms |
156572 KB |
Output is correct |
32 |
Correct |
291 ms |
156544 KB |
Output is correct |
33 |
Correct |
271 ms |
156604 KB |
Output is correct |
34 |
Correct |
291 ms |
156744 KB |
Output is correct |
35 |
Correct |
276 ms |
156612 KB |
Output is correct |
36 |
Correct |
281 ms |
156632 KB |
Output is correct |