# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857186 | 2023-10-05T14:01:40 Z | Trisanu_Das | Nautilus (BOI19_nautilus) | C++17 | 163 ms | 1372 KB |
#include <bits/stdc++.h> using namespace std; int r,c,m; vector<string> a; bool valid_pos(int i, int j){ return !(i < 0 || j < 0 || i >= r || j >= c || a[i][j] == '#'); } int main(){ cin >> r >> c >> m; a.resize(r); for(int i = 0; i < r; ++i) cin >> a[i]; string msg; cin >> msg; bitset<1000> dp[r],temp[r],aa[r]; for(int i = 0; i < r; ++i){ for(int j = 0; j < c; ++j){ aa[i][j] = a[i][c-1-j] == '.'; dp[i][j] = a[i][c-1-j] == '.'; } } for(char w : msg){ for(int i = 0; i < r; ++i){ if(w == 'W') dp[i] = (dp[i]<<1)&aa[i]; if(w == 'E') dp[i] = (dp[i]>>1)&aa[i]; if(w == 'N') if(i+1 < r) dp[i] = dp[i+1]&aa[i]; else dp[i].reset(); if(w == '?'){ temp[i] = (dp[i]<<1)|(dp[i]>>1); if(i) temp[i] |= dp[i-1]; if(i+1 < r) temp[i] |= dp[i+1]; temp[i] &= aa[i]; } } for(int i = r-1; i >= 0; --i) if(w == 'S') if(i) dp[i] = dp[i-1]&aa[i]; else dp[i].reset(); for(int i = 0; i < r; ++i) if(w == '?') dp[i] = temp[i]; } int ans = 0; for(int i = 0; i < r; ++i) ans += dp[i].count(); cout << ans << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 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 | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 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 | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 348 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 | 1 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 | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 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 | 344 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 | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 348 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 | 1 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 | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 84 ms | 1368 KB | Output is correct |
23 | Correct | 86 ms | 1168 KB | Output is correct |
24 | Correct | 84 ms | 1368 KB | Output is correct |
25 | Correct | 83 ms | 1368 KB | Output is correct |
26 | Correct | 89 ms | 1372 KB | Output is correct |
27 | Correct | 123 ms | 1372 KB | Output is correct |
28 | Correct | 123 ms | 1368 KB | Output is correct |
29 | Correct | 124 ms | 1368 KB | Output is correct |
30 | Correct | 126 ms | 1352 KB | Output is correct |
31 | Correct | 120 ms | 1372 KB | Output is correct |
32 | Correct | 152 ms | 1372 KB | Output is correct |
33 | Correct | 153 ms | 1372 KB | Output is correct |
34 | Correct | 163 ms | 1372 KB | Output is correct |
35 | Correct | 151 ms | 1368 KB | Output is correct |
36 | Correct | 153 ms | 1368 KB | Output is correct |