Submission #390972

# Submission time Handle Problem Language Result Execution time Memory
390972 2021-04-17T13:07:30 Z ForTrain Nautilus (BOI19_nautilus) C++14
100 / 100
645 ms 1092 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ppb pop_back
#define x first
#define y second
#define int long long
#define mp make_pair
#define cmpl complex <long double>

using namespace std;

const int sz = 5e5;

signed main (){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, k;
    char x;
    cin >> n >> m >> k;
    bitset <sz> ans, pos1, pos2, p, temp;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            cin >> x;
            if (x == '.') ans[i * m + j] = 1;
            p[i * m + j] = ans[i * m + j];
            pos1[i * m + j] = (j != 0);
            pos2[i * m + j] = (j != m - 1);
        }
    }
    int res = 0;
    string s;
    cin >> s;
    for (int i = 0; i < k; ++i){
        temp = ans;
        ans.reset();
        if (s[i] == 'S' || s[i] == '?') ans |= (temp << m);
        if (s[i] == 'N' || s[i] == '?') ans |= (temp >> m);
        if (s[i] == 'E' || s[i] == '?') ans |= (temp << 1) & pos1;
        if (s[i] == 'W' || s[i] == '?') ans |= (temp >> 1) & pos2;
        ans = ans & p;
    }
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            res += ans[i * m + j];
        }
    }
    cout << res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 716 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 716 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
7 Correct 7 ms 716 KB Output is correct
8 Correct 7 ms 716 KB Output is correct
9 Correct 9 ms 752 KB Output is correct
10 Correct 8 ms 752 KB Output is correct
11 Correct 8 ms 708 KB Output is correct
12 Correct 10 ms 752 KB Output is correct
13 Correct 11 ms 752 KB Output is correct
14 Correct 11 ms 844 KB Output is correct
15 Correct 11 ms 716 KB Output is correct
16 Correct 11 ms 752 KB Output is correct
17 Correct 16 ms 756 KB Output is correct
18 Correct 12 ms 748 KB Output is correct
19 Correct 12 ms 744 KB Output is correct
20 Correct 13 ms 756 KB Output is correct
21 Correct 13 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 716 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
7 Correct 7 ms 716 KB Output is correct
8 Correct 7 ms 716 KB Output is correct
9 Correct 9 ms 752 KB Output is correct
10 Correct 8 ms 752 KB Output is correct
11 Correct 8 ms 708 KB Output is correct
12 Correct 10 ms 752 KB Output is correct
13 Correct 11 ms 752 KB Output is correct
14 Correct 11 ms 844 KB Output is correct
15 Correct 11 ms 716 KB Output is correct
16 Correct 11 ms 752 KB Output is correct
17 Correct 16 ms 756 KB Output is correct
18 Correct 12 ms 748 KB Output is correct
19 Correct 12 ms 744 KB Output is correct
20 Correct 13 ms 756 KB Output is correct
21 Correct 13 ms 740 KB Output is correct
22 Correct 339 ms 980 KB Output is correct
23 Correct 326 ms 976 KB Output is correct
24 Correct 323 ms 976 KB Output is correct
25 Correct 316 ms 988 KB Output is correct
26 Correct 326 ms 988 KB Output is correct
27 Correct 456 ms 1092 KB Output is correct
28 Correct 473 ms 988 KB Output is correct
29 Correct 467 ms 976 KB Output is correct
30 Correct 516 ms 1092 KB Output is correct
31 Correct 456 ms 1000 KB Output is correct
32 Correct 568 ms 984 KB Output is correct
33 Correct 575 ms 980 KB Output is correct
34 Correct 645 ms 972 KB Output is correct
35 Correct 580 ms 972 KB Output is correct
36 Correct 575 ms 972 KB Output is correct