# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
670110 |
2022-12-08T06:53:03 Z |
nonono |
Nautilus (BOI19_nautilus) |
C++17 |
|
304 ms |
153872 KB |
#include "bits/stdc++.h"
using namespace std;
const char c[] = {'N', 'E', 'S', 'W'};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
typedef bitset<250000> B;
const int mxN = 501, mxM = 5e3 + 1;
int n, m, q;
B dp[mxM], f, d, dd[5];
string s;
int change(int a, int b){
return a * m + b;
}
int main(){
#define file "nautilus"
if(fopen(file".inp", "r")){
freopen(file".inp", "r", stdin);
freopen(file".out", "w", stdout);
}
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> q;
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
char x; cin >> x;
f[change(i, j)] = dp[0][change(i, j)] = (x == '.');
}
}
cin >> s;
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
d[change(i, j)] = 1;
}
}
for(int i = 0; i < 4; i ++){
dd[i] = d;
if(i == 0){
for(int j = 0; j < m; j ++)
dd[i][change(0, j)] = 0;
}
if(i == 1){
for(int j = 0; j < n; j ++)
dd[i][change(j , m - 1)] = 0;
}
if(i == 2){
for(int j = 0; j < m; j ++)
dd[i][change(n - 1, j)] = 0;
}
if(i == 3){
for(int j = 0; j < n; j ++)
dd[i][change(j, 0)] = 0;
}
}
for(int i = 0; i < q; i ++){
for(int t = 0; t < 4; t ++){
if(c[t] == s[i] || s[i] == '?'){
int x = change(dx[t], dy[t]);
if(x >= 0) dp[i + 1] |= ((dp[i] & dd[t]) << x);
else dp[i + 1] |= ((dp[i] & dd[t]) >> abs(x));
}
}
dp[i + 1] = (dp[i + 1] & f);
}
cout << (int)(dp[q].count()) << "\n";
return 0;
}
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | freopen(file".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | freopen(file".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3540 KB |
Output is correct |
2 |
Correct |
4 ms |
3540 KB |
Output is correct |
3 |
Correct |
6 ms |
3628 KB |
Output is correct |
4 |
Correct |
4 ms |
3632 KB |
Output is correct |
5 |
Correct |
5 ms |
3536 KB |
Output is correct |
6 |
Correct |
4 ms |
3628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3540 KB |
Output is correct |
2 |
Correct |
4 ms |
3540 KB |
Output is correct |
3 |
Correct |
6 ms |
3628 KB |
Output is correct |
4 |
Correct |
4 ms |
3632 KB |
Output is correct |
5 |
Correct |
5 ms |
3536 KB |
Output is correct |
6 |
Correct |
4 ms |
3628 KB |
Output is correct |
7 |
Correct |
4 ms |
3628 KB |
Output is correct |
8 |
Correct |
6 ms |
3540 KB |
Output is correct |
9 |
Correct |
8 ms |
3632 KB |
Output is correct |
10 |
Correct |
5 ms |
3540 KB |
Output is correct |
11 |
Correct |
5 ms |
3540 KB |
Output is correct |
12 |
Correct |
5 ms |
3636 KB |
Output is correct |
13 |
Correct |
6 ms |
3540 KB |
Output is correct |
14 |
Correct |
6 ms |
3540 KB |
Output is correct |
15 |
Correct |
6 ms |
3632 KB |
Output is correct |
16 |
Correct |
6 ms |
3540 KB |
Output is correct |
17 |
Correct |
7 ms |
3540 KB |
Output is correct |
18 |
Correct |
12 ms |
3544 KB |
Output is correct |
19 |
Correct |
11 ms |
3572 KB |
Output is correct |
20 |
Correct |
7 ms |
3612 KB |
Output is correct |
21 |
Correct |
7 ms |
3540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3540 KB |
Output is correct |
2 |
Correct |
4 ms |
3540 KB |
Output is correct |
3 |
Correct |
6 ms |
3628 KB |
Output is correct |
4 |
Correct |
4 ms |
3632 KB |
Output is correct |
5 |
Correct |
5 ms |
3536 KB |
Output is correct |
6 |
Correct |
4 ms |
3628 KB |
Output is correct |
7 |
Correct |
4 ms |
3628 KB |
Output is correct |
8 |
Correct |
6 ms |
3540 KB |
Output is correct |
9 |
Correct |
8 ms |
3632 KB |
Output is correct |
10 |
Correct |
5 ms |
3540 KB |
Output is correct |
11 |
Correct |
5 ms |
3540 KB |
Output is correct |
12 |
Correct |
5 ms |
3636 KB |
Output is correct |
13 |
Correct |
6 ms |
3540 KB |
Output is correct |
14 |
Correct |
6 ms |
3540 KB |
Output is correct |
15 |
Correct |
6 ms |
3632 KB |
Output is correct |
16 |
Correct |
6 ms |
3540 KB |
Output is correct |
17 |
Correct |
7 ms |
3540 KB |
Output is correct |
18 |
Correct |
12 ms |
3544 KB |
Output is correct |
19 |
Correct |
11 ms |
3572 KB |
Output is correct |
20 |
Correct |
7 ms |
3612 KB |
Output is correct |
21 |
Correct |
7 ms |
3540 KB |
Output is correct |
22 |
Correct |
188 ms |
153676 KB |
Output is correct |
23 |
Correct |
212 ms |
153672 KB |
Output is correct |
24 |
Correct |
203 ms |
153720 KB |
Output is correct |
25 |
Correct |
190 ms |
153700 KB |
Output is correct |
26 |
Correct |
182 ms |
153684 KB |
Output is correct |
27 |
Correct |
259 ms |
153692 KB |
Output is correct |
28 |
Correct |
249 ms |
153676 KB |
Output is correct |
29 |
Correct |
245 ms |
153792 KB |
Output is correct |
30 |
Correct |
241 ms |
153676 KB |
Output is correct |
31 |
Correct |
233 ms |
153740 KB |
Output is correct |
32 |
Correct |
304 ms |
153684 KB |
Output is correct |
33 |
Correct |
281 ms |
153872 KB |
Output is correct |
34 |
Correct |
287 ms |
153740 KB |
Output is correct |
35 |
Correct |
284 ms |
153748 KB |
Output is correct |
36 |
Correct |
301 ms |
153752 KB |
Output is correct |