Submission #981150

# Submission time Handle Problem Language Result Execution time Memory
981150 2024-05-12T22:35:45 Z ShaShi Nautilus (BOI19_nautilus) C++17
100 / 100
163 ms 1108 KB
#include <bits/stdc++.h>
// #define int long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define kill(x) cout << x << endl, exit(0);
#define endl "\n"

 
using namespace std;
typedef long long ll;
typedef long double ld;
 

const int MAXN = (int)500 + 7;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;


int n, m, q, tmp, tmp2, tmp3, tmp4, ans, k, u, v, w, flag;
int arr[MAXN][MAXN], arr2[MAXN][MAXN];
// bool bad[MAXN][MAXN];
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int cnt[][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {1, 1, 1, 1}};
string s; char ch;

bitset<MAXN*MAXN> bst, bad;



int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m >> k;
    
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            cin >> ch;

            if (ch == '.') bst[(i-1)*(m+1)+j] = bad[(i-1)*(m+1)+j] = 1;
        }
    }

    cin >> s;

    for (int i=0; i<k; i++) {
        if (s[i] == 'N') {
            bst = (bst>>(m+1)) & bad;
        } else if (s[i] == 'S') {
            bst = (bst<<(m+1)) & bad;
        } else if (s[i] == 'E') {
            bst = (bst<<1) & bad;
        } else if (s[i] == 'W') {
            bst = (bst>>1) & bad;
        } else {
            bst = ((bst>>(m+1)) | ((bst<<(m+1))) | (bst<<1) | (bst>>1))&bad;
        }
    }
    
    cout << bst.count() << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 780 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 780 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 776 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 780 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 776 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
22 Correct 69 ms 796 KB Output is correct
23 Correct 74 ms 860 KB Output is correct
24 Correct 71 ms 860 KB Output is correct
25 Correct 75 ms 1044 KB Output is correct
26 Correct 70 ms 980 KB Output is correct
27 Correct 107 ms 1048 KB Output is correct
28 Correct 115 ms 1048 KB Output is correct
29 Correct 111 ms 856 KB Output is correct
30 Correct 111 ms 860 KB Output is correct
31 Correct 106 ms 1028 KB Output is correct
32 Correct 140 ms 1108 KB Output is correct
33 Correct 140 ms 1016 KB Output is correct
34 Correct 163 ms 1016 KB Output is correct
35 Correct 142 ms 1020 KB Output is correct
36 Correct 139 ms 860 KB Output is correct