답안 #207059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207059 2020-03-06T09:24:28 Z gratus907 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 1784 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-20
using pii = pair <int, int>;

int r, c, m;
char message[5050];
bool dp[2][550][550];
char mp[550][550];
bool bd[550][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++)
                for (int j = 1; j<=c; j++)
                    dp[t][i][j] &= dp[b][i][j-1];
        }
        else if (message[id] == 'W')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i][j] &= dp[b][i][j+1];
        }
        else if (message[id] == 'N')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i][j] &= dp[b][i+1][j];
        }
        else if (message[id] == 'S')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i][j] &= dp[b][i-1][j];
        }
        else if (message[id] == '?')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i][j] &= dp[b][i+1][j] || dp[b][i-1][j] || dp[b][i][j+1] || dp[b][i][j-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 8 ms 1016 KB Output is correct
2 Correct 7 ms 1016 KB Output is correct
3 Correct 8 ms 1016 KB Output is correct
4 Correct 8 ms 1016 KB Output is correct
5 Correct 7 ms 1016 KB Output is correct
6 Correct 8 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1016 KB Output is correct
2 Correct 7 ms 1016 KB Output is correct
3 Correct 8 ms 1016 KB Output is correct
4 Correct 8 ms 1016 KB Output is correct
5 Correct 7 ms 1016 KB Output is correct
6 Correct 8 ms 1016 KB Output is correct
7 Correct 9 ms 1016 KB Output is correct
8 Correct 9 ms 1016 KB Output is correct
9 Correct 9 ms 1016 KB Output is correct
10 Correct 8 ms 1016 KB Output is correct
11 Correct 8 ms 1016 KB Output is correct
12 Correct 8 ms 1016 KB Output is correct
13 Correct 11 ms 1016 KB Output is correct
14 Correct 13 ms 1016 KB Output is correct
15 Correct 9 ms 1016 KB Output is correct
16 Correct 9 ms 1016 KB Output is correct
17 Correct 9 ms 1020 KB Output is correct
18 Correct 11 ms 1016 KB Output is correct
19 Correct 13 ms 1016 KB Output is correct
20 Correct 11 ms 1016 KB Output is correct
21 Correct 9 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1016 KB Output is correct
2 Correct 7 ms 1016 KB Output is correct
3 Correct 8 ms 1016 KB Output is correct
4 Correct 8 ms 1016 KB Output is correct
5 Correct 7 ms 1016 KB Output is correct
6 Correct 8 ms 1016 KB Output is correct
7 Correct 9 ms 1016 KB Output is correct
8 Correct 9 ms 1016 KB Output is correct
9 Correct 9 ms 1016 KB Output is correct
10 Correct 8 ms 1016 KB Output is correct
11 Correct 8 ms 1016 KB Output is correct
12 Correct 8 ms 1016 KB Output is correct
13 Correct 11 ms 1016 KB Output is correct
14 Correct 13 ms 1016 KB Output is correct
15 Correct 9 ms 1016 KB Output is correct
16 Correct 9 ms 1016 KB Output is correct
17 Correct 9 ms 1020 KB Output is correct
18 Correct 11 ms 1016 KB Output is correct
19 Correct 13 ms 1016 KB Output is correct
20 Correct 11 ms 1016 KB Output is correct
21 Correct 9 ms 1016 KB Output is correct
22 Correct 529 ms 1752 KB Output is correct
23 Correct 969 ms 1784 KB Output is correct
24 Correct 730 ms 1784 KB Output is correct
25 Correct 730 ms 1784 KB Output is correct
26 Correct 712 ms 1784 KB Output is correct
27 Correct 869 ms 1656 KB Output is correct
28 Execution timed out 1076 ms 1656 KB Time limit exceeded
29 Halted 0 ms 0 KB -