Submission #834167

# Submission time Handle Problem Language Result Execution time Memory
834167 2023-08-22T11:26:52 Z TheSahib Nautilus (BOI19_nautilus) C++14
100 / 100
103 ms 580 KB
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define oo 1e9
#define pii pair<int, int>

using namespace std;

int n, m, q;
const int MAX = 503;

bitset<MAX * MAX> st, can;

int main()
{
    cin >> n >> m >> q;
    for (int i = 0; i < n; i++)
    {
        string s; cin >> s;
        can[i * (m + 2)] = 0;
        can[(i + 1) * (m + 2) - 1] = 0;
        for (int j = 1; j <= m; j++)
        {
            can[i * (m + 2) + j] = s[j - 1] == '.';
        }
    }
    st = can;
    string s; cin >> s;
    for (int i = 0; i < q; i++)
    {
        if(s[i] == 'W'){
            st >>= 1;
        }
        else if(s[i] == 'S'){
            st <<= m + 2;
        }
        else if(s[i] == 'E'){
            st <<= 1;
        }
        else if(s[i] == 'N'){
            st >>= m + 2;
        }
        else{
            st = (st << 1) | (st >> 1) | (st << (m + 2)) | (st >> (m + 2));
        }
        st &= can;
    }
    cout << st.count() << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 43 ms 568 KB Output is correct
23 Correct 43 ms 468 KB Output is correct
24 Correct 43 ms 564 KB Output is correct
25 Correct 41 ms 468 KB Output is correct
26 Correct 41 ms 468 KB Output is correct
27 Correct 77 ms 576 KB Output is correct
28 Correct 72 ms 576 KB Output is correct
29 Correct 73 ms 568 KB Output is correct
30 Correct 74 ms 564 KB Output is correct
31 Correct 73 ms 568 KB Output is correct
32 Correct 100 ms 568 KB Output is correct
33 Correct 97 ms 468 KB Output is correct
34 Correct 97 ms 568 KB Output is correct
35 Correct 103 ms 568 KB Output is correct
36 Correct 100 ms 580 KB Output is correct