답안 #679569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679569 2023-01-08T14:31:24 Z lam Nautilus (BOI19_nautilus) C++14
100 / 100
215 ms 160172 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
const int maxm = 50010;
bitset<500> a[maxn],dp[maxm][maxn];
int n,m,L;
void E(int id)
{
    for (int i=1; i<=n; i++)
        dp[id][i]|=(dp[id-1][i]<<1);
}
void W(int id)
{
    for (int i=1; i<=n; i++)
        dp[id][i]|=(dp[id-1][i]>>1);
}
void N(int id)
{
    for (int i=1; i<n; i++)
        dp[id][i]|=(dp[id-1][i+1]);
}
void S(int id)
{
    for (int i=2; i<=n; i++)
        dp[id][i]|=(dp[id-1][i-1]);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n>>m>>L;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
    {
        char c; cin>>c;
        if (c=='.') a[i].set(j-1,1), dp[0][i].set(j-1,1);
    }
    for (int i=1; i<=L; i++)
    {
        char c; cin>>c;
        if (c=='N') N(i);
        else if (c=='S') S(i);
        else if (c=='W') W(i);
        else if (c=='E') E(i);
        else
        {
            N(i);
            S(i);
            W(i);
            E(i);
        }
        for (int j=1; j<=n; j++) dp[i][j]&=a[j];
    }
    int ans=0;
    for (int i=1; i<=n; i++)
        for (int j=0; j<m; j++) ans+=dp[L][i][j];
    cout<<ans;

}
/**
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1364 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 1 ms 1364 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 1 ms 1364 KB Output is correct
21 Correct 1 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1364 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 1 ms 1364 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 1 ms 1364 KB Output is correct
21 Correct 1 ms 1364 KB Output is correct
22 Correct 136 ms 160172 KB Output is correct
23 Correct 143 ms 160016 KB Output is correct
24 Correct 135 ms 160064 KB Output is correct
25 Correct 131 ms 160060 KB Output is correct
26 Correct 128 ms 159940 KB Output is correct
27 Correct 170 ms 160044 KB Output is correct
28 Correct 169 ms 159960 KB Output is correct
29 Correct 188 ms 160056 KB Output is correct
30 Correct 172 ms 160016 KB Output is correct
31 Correct 167 ms 159908 KB Output is correct
32 Correct 202 ms 160028 KB Output is correct
33 Correct 206 ms 160148 KB Output is correct
34 Correct 204 ms 159940 KB Output is correct
35 Correct 215 ms 160000 KB Output is correct
36 Correct 200 ms 159904 KB Output is correct