Submission #1106777

# Submission time Handle Problem Language Result Execution time Memory
1106777 2024-10-31T04:14:42 Z minhvule Nautilus (BOI19_nautilus) C++17
100 / 100
144 ms 158888 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define freo(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
#define FOR(i, a, b) for(int i=(a),_b = (b); i<=_b; i++)
#define FORD(i, a, b) for(int i=(a),_b = (b); i>=_b; i--)
#define bit(x, i) ((x >> i) & 1)
#define oo 1e18
#define pii pair<int, int>
#define debug cout<<"VUDEPTRAI\n";
using namespace std;
// mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
// ll rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll>(l, r)(rd); }
const int N = 5e3 + 5;
int r, c, m, ans = 0;
char a[505][505];
string s;
bitset<505> dp[N][505], mask[505];
void solve(){
    cin>>r>>c>>m;
    FOR(i, 1, r)
        FOR(j, 1, c)
            cin>>a[i][j];
    cin>>s;
    s = ' ' + s;
    FOR(i, 1, r)
        FOR(j, 1, c)
            if(a[i][j] == '.') dp[0][i].set(j), mask[i].set(j);
    FOR(i, 1, m)
        FOR(row, 1, r){
            if(s[i] == '?' || s[i] == 'N') dp[i][row] |= dp[i - 1][row + 1];
            if(s[i] == '?' || s[i] == 'S') dp[i][row] |= dp[i - 1][row - 1];
            if(s[i] == '?' || s[i] == 'E') dp[i][row] |= (dp[i - 1][row] << 1);
            if(s[i] == '?' || s[i] == 'W') dp[i][row] |= (dp[i - 1][row] >> 1);
            dp[i][row] &= mask[row];
        }
    FOR(row, 1, r) ans += dp[m][row].count();
    cout<<ans;
}
int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    // freo("");
    int nTest = 1;
    // cin>>nTest;
    while(nTest --) solve();
    // cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}
/*
 


*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4680 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 2 ms 4432 KB Output is correct
5 Correct 1 ms 4604 KB Output is correct
6 Correct 1 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4680 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 2 ms 4432 KB Output is correct
5 Correct 1 ms 4604 KB Output is correct
6 Correct 1 ms 4600 KB Output is correct
7 Correct 2 ms 4600 KB Output is correct
8 Correct 2 ms 4432 KB Output is correct
9 Correct 2 ms 4432 KB Output is correct
10 Correct 2 ms 4432 KB Output is correct
11 Correct 2 ms 4432 KB Output is correct
12 Correct 2 ms 4432 KB Output is correct
13 Correct 1 ms 4688 KB Output is correct
14 Correct 2 ms 4432 KB Output is correct
15 Correct 2 ms 4432 KB Output is correct
16 Correct 2 ms 4432 KB Output is correct
17 Correct 1 ms 4432 KB Output is correct
18 Correct 2 ms 4432 KB Output is correct
19 Correct 2 ms 4432 KB Output is correct
20 Correct 2 ms 4672 KB Output is correct
21 Correct 2 ms 4432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4680 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 2 ms 4432 KB Output is correct
5 Correct 1 ms 4604 KB Output is correct
6 Correct 1 ms 4600 KB Output is correct
7 Correct 2 ms 4600 KB Output is correct
8 Correct 2 ms 4432 KB Output is correct
9 Correct 2 ms 4432 KB Output is correct
10 Correct 2 ms 4432 KB Output is correct
11 Correct 2 ms 4432 KB Output is correct
12 Correct 2 ms 4432 KB Output is correct
13 Correct 1 ms 4688 KB Output is correct
14 Correct 2 ms 4432 KB Output is correct
15 Correct 2 ms 4432 KB Output is correct
16 Correct 2 ms 4432 KB Output is correct
17 Correct 1 ms 4432 KB Output is correct
18 Correct 2 ms 4432 KB Output is correct
19 Correct 2 ms 4432 KB Output is correct
20 Correct 2 ms 4672 KB Output is correct
21 Correct 2 ms 4432 KB Output is correct
22 Correct 76 ms 158792 KB Output is correct
23 Correct 83 ms 158792 KB Output is correct
24 Correct 79 ms 158792 KB Output is correct
25 Correct 82 ms 158888 KB Output is correct
26 Correct 86 ms 158792 KB Output is correct
27 Correct 110 ms 158792 KB Output is correct
28 Correct 108 ms 158672 KB Output is correct
29 Correct 116 ms 158716 KB Output is correct
30 Correct 121 ms 158792 KB Output is correct
31 Correct 116 ms 158804 KB Output is correct
32 Correct 128 ms 158664 KB Output is correct
33 Correct 127 ms 158868 KB Output is correct
34 Correct 126 ms 158804 KB Output is correct
35 Correct 138 ms 158792 KB Output is correct
36 Correct 144 ms 158792 KB Output is correct