Submission #957252

# Submission time Handle Problem Language Result Execution time Memory
957252 2024-04-03T10:21:41 Z n3rm1n Nautilus (BOI19_nautilus) C++17
100 / 100
235 ms 187004 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 515, MAXM = 6e3, MAXCELL = 3e5;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, m, t;
int a[MAXN][MAXN];
string operations;
bitset < MAXCELL > fr;
void read()
{
    cin >> n >> m >> t;
    char s;
    m += 2; /// border 0
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = 1; j <= m-2; ++ j)
        {
            cin >> s;
            if(s == '#')a[i][j] = 1;
            else fr[(i - 1) * m + j] = 1;
        }
    }
    cin >> operations;
    operations = '+' + operations;
}

bitset < MAXCELL > bs[MAXM];

void solve()
{
    bs[0] = fr;
    for (int i = 1; i <= t; ++ i)
    {
        bs[i] = 0;
        if(operations[i] == 'N')
        {

            bs[i] = (bs[i-1] >> m);

            bs[i] = (bs[i] & fr);
        }
        if(operations[i] == 'S')
        {

            bs[i] = ((bs[i-1] << m) & fr);
            bs[i] = (bs[i] & fr);
        }
        if(operations[i] == 'W' )
        {

            bs[i] = (bs[i-1] >> 1);
            bs[i] = (bs[i] & fr);
        }
        if(operations[i] == 'E')
        {

            bs[i] = (bs[i-1] << 1);
            bs[i] = (bs[i] & fr);
        }
        if(operations[i] == '?')
        {
            bs[i] = (((bs[i-1] << m) | (bs[i-1] >> 1)) | ((bs[i-1] << 1) | (bs[i-1] >> m)));
            bs[i] = (bs[i] & fr);
        }
    }
    bs[t] = (bs[t] & fr);
    cout << bs[t].count() << endl;
}
int main()
{
    speed();

    read();
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 9 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 2 ms 5200 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 9 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 2 ms 5200 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 3 ms 5204 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 4 ms 4956 KB Output is correct
13 Correct 4 ms 4956 KB Output is correct
14 Correct 4 ms 4956 KB Output is correct
15 Correct 5 ms 5212 KB Output is correct
16 Correct 5 ms 4956 KB Output is correct
17 Correct 4 ms 4952 KB Output is correct
18 Correct 5 ms 4956 KB Output is correct
19 Correct 5 ms 5212 KB Output is correct
20 Correct 5 ms 4956 KB Output is correct
21 Correct 7 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 9 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 2 ms 5200 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 3 ms 5204 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 4 ms 4956 KB Output is correct
13 Correct 4 ms 4956 KB Output is correct
14 Correct 4 ms 4956 KB Output is correct
15 Correct 5 ms 5212 KB Output is correct
16 Correct 5 ms 4956 KB Output is correct
17 Correct 4 ms 4952 KB Output is correct
18 Correct 5 ms 4956 KB Output is correct
19 Correct 5 ms 5212 KB Output is correct
20 Correct 5 ms 4956 KB Output is correct
21 Correct 7 ms 4956 KB Output is correct
22 Correct 235 ms 185552 KB Output is correct
23 Correct 137 ms 186960 KB Output is correct
24 Correct 116 ms 186640 KB Output is correct
25 Correct 129 ms 186744 KB Output is correct
26 Correct 120 ms 186708 KB Output is correct
27 Correct 167 ms 186056 KB Output is correct
28 Correct 167 ms 186704 KB Output is correct
29 Correct 167 ms 186788 KB Output is correct
30 Correct 186 ms 187004 KB Output is correct
31 Correct 177 ms 186708 KB Output is correct
32 Correct 199 ms 185772 KB Output is correct
33 Correct 218 ms 186892 KB Output is correct
34 Correct 215 ms 186708 KB Output is correct
35 Correct 203 ms 186840 KB Output is correct
36 Correct 222 ms 186832 KB Output is correct