답안 #207064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207064 2020-03-06T09:34:04 Z gratus907 Nautilus (BOI19_nautilus) C++17
100 / 100
58 ms 1020 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define eps 1e-7
using pii = pair <int, int>;

int r, c, m;
char message[5050];
bitset<550> dp[2][550];
char mp[550][550];
bitset<550> bd[550];
int32_t main()
{
    scanf("%d %d %d\n",&r,&c,&m);
    for (int i = 1; i<=r; i++)
        scanf(" %s",&mp[i][1]);
    scanf(" %s",message+1);
    for (int i = 1; i<=r; i++)
        for (int j = 1; j<=c; j++)
            bd[i][j] = (mp[i][j]=='#'?0:1);

    memcpy(dp[0],bd,sizeof(dp[0]));
    for (int id = 1; id<=m; id++)
    {
        int t = id%2, b = 1-t;
        memcpy(dp[t],bd,sizeof(dp[t]));
        if (message[id] == 'E')
        {
            for (int i = 1; i<=r; i++)
                dp[t][i] &= (dp[b][i]<<1);
        }
        else if (message[id] == 'W')
        {
            for (int i = 1; i<=r; i++)
                dp[t][i] &= (dp[b][i]>>1);
        }
        else if (message[id] == 'N')
        {
            for (int i = 1; i<=r; i++)
                dp[t][i] &= dp[b][i+1];
        }
        else if (message[id] == 'S')
        {
            for (int i = 1; i<=r; i++)
                dp[t][i] &= dp[b][i-1];
        }
        else if (message[id] == '?')
        {
            for (int i = 1; i<=r; i++)
                dp[t][i] &= (dp[b][i+1] | dp[b][i-1] | dp[b][i]>>1 | dp[b][i]<<1);
        }
    }
    int ans = 0;
    for (int i = 1; i<=r; i++)
        for (int j = 1; j<=c; j++)
            ans += (dp[m%2][i][j]?1:0);
    printf("%d\n",ans);
}

Compilation message

nautilus.cpp: In function 'int32_t main()':
nautilus.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d\n",&r,&c,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",&mp[i][1]);
         ~~~~~^~~~~~~~~~~~~~~~~
nautilus.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s",message+1);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 508 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
19 Correct 5 ms 508 KB Output is correct
20 Correct 5 ms 504 KB Output is correct
21 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 508 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
19 Correct 5 ms 508 KB Output is correct
20 Correct 5 ms 504 KB Output is correct
21 Correct 5 ms 504 KB Output is correct
22 Correct 33 ms 892 KB Output is correct
23 Correct 34 ms 632 KB Output is correct
24 Correct 33 ms 632 KB Output is correct
25 Correct 33 ms 760 KB Output is correct
26 Correct 34 ms 760 KB Output is correct
27 Correct 40 ms 764 KB Output is correct
28 Correct 52 ms 760 KB Output is correct
29 Correct 48 ms 1016 KB Output is correct
30 Correct 43 ms 1016 KB Output is correct
31 Correct 45 ms 888 KB Output is correct
32 Correct 47 ms 1004 KB Output is correct
33 Correct 43 ms 888 KB Output is correct
34 Correct 43 ms 1016 KB Output is correct
35 Correct 58 ms 1016 KB Output is correct
36 Correct 54 ms 1020 KB Output is correct