답안 #207060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207060 2020-03-06T09:25:12 Z gratus907 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 1632 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
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:11: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:13: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:14: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 7 ms 1020 KB Output is correct
4 Correct 7 ms 1016 KB Output is correct
5 Correct 8 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 7 ms 1020 KB Output is correct
4 Correct 7 ms 1016 KB Output is correct
5 Correct 8 ms 1016 KB Output is correct
6 Correct 8 ms 1016 KB Output is correct
7 Correct 8 ms 1020 KB Output is correct
8 Correct 9 ms 1016 KB Output is correct
9 Correct 8 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 14 ms 1016 KB Output is correct
15 Correct 9 ms 1020 KB Output is correct
16 Correct 8 ms 1020 KB Output is correct
17 Correct 9 ms 1016 KB Output is correct
18 Correct 11 ms 1016 KB Output is correct
19 Correct 16 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 7 ms 1020 KB Output is correct
4 Correct 7 ms 1016 KB Output is correct
5 Correct 8 ms 1016 KB Output is correct
6 Correct 8 ms 1016 KB Output is correct
7 Correct 8 ms 1020 KB Output is correct
8 Correct 9 ms 1016 KB Output is correct
9 Correct 8 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 14 ms 1016 KB Output is correct
15 Correct 9 ms 1020 KB Output is correct
16 Correct 8 ms 1020 KB Output is correct
17 Correct 9 ms 1016 KB Output is correct
18 Correct 11 ms 1016 KB Output is correct
19 Correct 16 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 664 ms 1508 KB Output is correct
23 Execution timed out 1048 ms 1632 KB Time limit exceeded
24 Halted 0 ms 0 KB -