Submission #417975

# Submission time Handle Problem Language Result Execution time Memory
417975 2021-06-04T17:56:03 Z JerryLiu06 Nautilus (BOI19_nautilus) C++17
100 / 100
283 ms 160332 KB
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using db = double;
using str = string;
 
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
 
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
 
#define mp make_pair
#define f first
#define s second
 
#define sz(x) (int)(x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define ft front()
#define bk back()
#define pb push_back
#define pf push_front
 
#define lb lower_bound
#define ub upper_bound
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define EACH(a,x) for (auto& a: x)
 
const int MOD = 1e9 + 7;
const int MXR = 510;
const int MXM = 5010;
const ll INF = 2e18 + 10; 

int R, C, M; string S; bitset<MXR> DP[MXM][MXR], grid[MXR];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> R >> C >> M; FOR(i, 1, R + 1) FOR(j, 1, C + 1) {
        char A; cin >> A; if (A == '.') { DP[0][i][j] = 1; grid[i][j] = 1; }
    }
    cin >> S; FOR(i, 1, sz(S) + 1) FOR(j, 1, R + 1) {
        if (S[i - 1] == 'N' || S[i - 1] == '?') DP[i][j] |= DP[i - 1][j + 1];
        if (S[i - 1] == 'S' || S[i - 1] == '?') DP[i][j] |= DP[i - 1][j - 1];

        if (S[i - 1] == 'W' || S[i - 1] == '?') DP[i][j] |= DP[i - 1][j] >> 1, DP[i][j][C + 1] = 0;
        if (S[i - 1] == 'E' || S[i - 1] == '?') DP[i][j] |= DP[i - 1][j] << 1, DP[i][j][0] = 0;

        DP[i][j] &= grid[j];
    }
    int ans = 0; FOR(i, 1, R + 1) ans += DP[M][i].count(); cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 1 ms 1228 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 1 ms 1228 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 2 ms 1216 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1356 KB Output is correct
10 Correct 2 ms 1356 KB Output is correct
11 Correct 2 ms 1356 KB Output is correct
12 Correct 2 ms 1356 KB Output is correct
13 Correct 2 ms 1356 KB Output is correct
14 Correct 3 ms 1356 KB Output is correct
15 Correct 2 ms 1356 KB Output is correct
16 Correct 2 ms 1228 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 2 ms 1356 KB Output is correct
19 Correct 2 ms 1356 KB Output is correct
20 Correct 2 ms 1356 KB Output is correct
21 Correct 3 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 1 ms 1228 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 2 ms 1216 KB Output is correct
8 Correct 2 ms 1356 KB Output is correct
9 Correct 2 ms 1356 KB Output is correct
10 Correct 2 ms 1356 KB Output is correct
11 Correct 2 ms 1356 KB Output is correct
12 Correct 2 ms 1356 KB Output is correct
13 Correct 2 ms 1356 KB Output is correct
14 Correct 3 ms 1356 KB Output is correct
15 Correct 2 ms 1356 KB Output is correct
16 Correct 2 ms 1228 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 2 ms 1356 KB Output is correct
19 Correct 2 ms 1356 KB Output is correct
20 Correct 2 ms 1356 KB Output is correct
21 Correct 3 ms 1356 KB Output is correct
22 Correct 177 ms 160240 KB Output is correct
23 Correct 185 ms 160332 KB Output is correct
24 Correct 178 ms 160236 KB Output is correct
25 Correct 179 ms 160240 KB Output is correct
26 Correct 175 ms 160196 KB Output is correct
27 Correct 224 ms 160324 KB Output is correct
28 Correct 225 ms 160260 KB Output is correct
29 Correct 224 ms 160196 KB Output is correct
30 Correct 223 ms 160232 KB Output is correct
31 Correct 222 ms 160224 KB Output is correct
32 Correct 257 ms 160236 KB Output is correct
33 Correct 269 ms 160324 KB Output is correct
34 Correct 261 ms 160324 KB Output is correct
35 Correct 283 ms 160316 KB Output is correct
36 Correct 260 ms 160316 KB Output is correct