Submission #420007

# Submission time Handle Problem Language Result Execution time Memory
420007 2021-06-07T21:45:19 Z ScarletS Nautilus (BOI19_nautilus) C++17
100 / 100
250 ms 708 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 505, K = 5005;
bitset<N> dp[2][N], sea[N];
char c[N][N];
string s;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    for (int i=1;i<=n;++i)
        for (int j=1;j<=m;++j)
        {
            cin>>c[i][j];
            dp[0][i][j]=sea[i][j]=(c[i][j]=='.');
        }
    cin>>s;
    for (auto x : s)
    {
        if (x=='N')
            for (int i=1;i<=n;++i)
                dp[1][i]=dp[0][i+1]&sea[i];
        else if (x=='S')
            for (int i=1;i<=n;++i)
                dp[1][i]=dp[0][i-1]&sea[i];
        else if (x=='E')
            for (int i=1;i<=n;++i)
                dp[1][i]=(dp[0][i]<<1)&sea[i];
        else if (x=='W')
            for (int i=1;i<=n;++i)
                dp[1][i]=(dp[0][i]>>1)&sea[i];
        else
            for (int i=1;i<=n;++i)
                dp[1][i]=(dp[0][i+1]|dp[0][i-1]|(dp[0][i]>>1)|(dp[0][i]<<1))&sea[i];
        for (int i=1;i<=n;++i)
            dp[0][i]=dp[1][i];
    }
    int ans = 0;
    for (int i=1;i<=n;++i)
        ans+=dp[0][i].count();
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 112 ms 648 KB Output is correct
23 Correct 112 ms 588 KB Output is correct
24 Correct 111 ms 708 KB Output is correct
25 Correct 108 ms 664 KB Output is correct
26 Correct 106 ms 588 KB Output is correct
27 Correct 188 ms 588 KB Output is correct
28 Correct 183 ms 588 KB Output is correct
29 Correct 188 ms 656 KB Output is correct
30 Correct 185 ms 648 KB Output is correct
31 Correct 181 ms 588 KB Output is correct
32 Correct 240 ms 664 KB Output is correct
33 Correct 243 ms 652 KB Output is correct
34 Correct 250 ms 652 KB Output is correct
35 Correct 240 ms 668 KB Output is correct
36 Correct 239 ms 588 KB Output is correct