Submission #897832

# Submission time Handle Problem Language Result Execution time Memory
897832 2024-01-03T18:41:01 Z maxFedorchuk Nautilus (BOI19_nautilus) C++17
100 / 100
566 ms 2132 KB
#include <bits/stdc++.h>
using namespace std;

const long long MX=1010;

bitset < MX*MX > ok;
bitset < MX*MX > dp;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n,m,k;
    cin>>n>>m>>k;

    char zn;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>zn;
            if(zn=='.')
            {
                ok[i*MX+j]=1;
            }
        }
    }

    dp=ok;

    string s;
    cin>>s;

    for(auto zr:s)
    {
        if(zr=='N')
        {
            dp=(dp>>MX);
        }

        if(zr=='S')
        {
            dp=(dp<<MX);
        }

        if(zr=='W')
        {
            dp=(dp>>1);
        }

        if(zr=='E')
        {
            dp=(dp<<1);
        }

        if(zr=='?')
        {
            dp=((dp<<MX)|(dp>>MX)|(dp<<1)|(dp>>1));
        }

        dp&=ok;
    }

    cout<<dp.count()<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 4 ms 1740 KB Output is correct
3 Correct 4 ms 1372 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 4 ms 1740 KB Output is correct
3 Correct 4 ms 1372 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 6 ms 1368 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 7 ms 1372 KB Output is correct
10 Correct 7 ms 1372 KB Output is correct
11 Correct 6 ms 1372 KB Output is correct
12 Correct 9 ms 1612 KB Output is correct
13 Correct 10 ms 1368 KB Output is correct
14 Correct 10 ms 1372 KB Output is correct
15 Correct 10 ms 1372 KB Output is correct
16 Correct 10 ms 1512 KB Output is correct
17 Correct 12 ms 1608 KB Output is correct
18 Correct 12 ms 1372 KB Output is correct
19 Correct 12 ms 1372 KB Output is correct
20 Correct 12 ms 1604 KB Output is correct
21 Correct 15 ms 1600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 4 ms 1740 KB Output is correct
3 Correct 4 ms 1372 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 6 ms 1368 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 7 ms 1372 KB Output is correct
10 Correct 7 ms 1372 KB Output is correct
11 Correct 6 ms 1372 KB Output is correct
12 Correct 9 ms 1612 KB Output is correct
13 Correct 10 ms 1368 KB Output is correct
14 Correct 10 ms 1372 KB Output is correct
15 Correct 10 ms 1372 KB Output is correct
16 Correct 10 ms 1512 KB Output is correct
17 Correct 12 ms 1608 KB Output is correct
18 Correct 12 ms 1372 KB Output is correct
19 Correct 12 ms 1372 KB Output is correct
20 Correct 12 ms 1604 KB Output is correct
21 Correct 15 ms 1600 KB Output is correct
22 Correct 266 ms 1884 KB Output is correct
23 Correct 264 ms 1884 KB Output is correct
24 Correct 256 ms 1880 KB Output is correct
25 Correct 263 ms 1880 KB Output is correct
26 Correct 248 ms 1876 KB Output is correct
27 Correct 412 ms 1884 KB Output is correct
28 Correct 425 ms 2132 KB Output is correct
29 Correct 435 ms 1884 KB Output is correct
30 Correct 460 ms 2132 KB Output is correct
31 Correct 415 ms 1628 KB Output is correct
32 Correct 566 ms 1884 KB Output is correct
33 Correct 540 ms 1880 KB Output is correct
34 Correct 540 ms 1852 KB Output is correct
35 Correct 544 ms 1884 KB Output is correct
36 Correct 543 ms 1628 KB Output is correct