Submission #941815

# Submission time Handle Problem Language Result Execution time Memory
941815 2024-03-09T13:33:50 Z phoenix0423 Nautilus (BOI19_nautilus) C++17
100 / 100
97 ms 848 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;

signed main(void){
    fastio;
    int r, c, m;
    cin>>r>>c>>m;
    vector<bitset<501>> st(r);
    for(int i = 0; i < r; i++){
        string s;
        cin>>s;
        for(int j = 0; j < c; j++){
            if(s[j] == '.') st[i][j] = 1;
        }
    }
    string op;
    cin>>op;
    vector<bitset<501>> cur(st);
    for(int i = 0; i < m; i++){
        vector<bitset<501>> nw(r);
        if(op[i] == 'E' || op[i] == '?'){
            for(int j = 0; j < r; j++){
                nw[j] |= (cur[j] << 1);
                nw[j] &= st[j];
            }
        }
        if(op[i] == 'W' || op[i] == '?'){
            for(int j = 0; j < r; j++){
                nw[j] |= (cur[j] >> 1);
                nw[j] &= st[j];
            }
        }
        if(op[i] == 'N' || op[i] == '?'){
            for(int j = r - 2; j >= 0; j--){
                nw[j] |= cur[j + 1];
                nw[j] &= st[j];
            }
        }
        if(op[i] == 'S' || op[i] == '?'){
            bitset<501> acc;
            for(int j = 1; j < r; j++){
                nw[j] |= cur[j - 1];
                nw[j] &= st[j];
            }
        }
        swap(cur, nw);
    }
    int ans = 0;
    for(int i = 0; i < r; i++) ans += cur[i].count();
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 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 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 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 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 47 ms 604 KB Output is correct
23 Correct 47 ms 604 KB Output is correct
24 Correct 46 ms 604 KB Output is correct
25 Correct 47 ms 600 KB Output is correct
26 Correct 44 ms 604 KB Output is correct
27 Correct 71 ms 804 KB Output is correct
28 Correct 71 ms 600 KB Output is correct
29 Correct 81 ms 800 KB Output is correct
30 Correct 75 ms 848 KB Output is correct
31 Correct 70 ms 604 KB Output is correct
32 Correct 91 ms 604 KB Output is correct
33 Correct 97 ms 832 KB Output is correct
34 Correct 91 ms 804 KB Output is correct
35 Correct 95 ms 604 KB Output is correct
36 Correct 90 ms 604 KB Output is correct