답안 #207063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207063 2020-03-06T09:33:19 Z gratus907 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 760 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++)
                for (int j = 1; j<=c; j++)
                    dp[t][i] &= (dp[b][i]<<1);
        }
        else if (message[id] == 'W')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i] &= (dp[b][i]>>1);
        }
        else if (message[id] == 'N')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i] &= dp[b][i+1];
        }
        else if (message[id] == 'S')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    dp[t][i] &= dp[b][i-1];
        }
        else if (message[id] == '?')
        {
            for (int i = 1; i<=r; i++)
                for (int j = 1; j<=c; j++)
                    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 14 ms 504 KB Output is correct
2 Correct 11 ms 504 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
4 Correct 11 ms 504 KB Output is correct
5 Correct 11 ms 504 KB Output is correct
6 Correct 10 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 504 KB Output is correct
2 Correct 11 ms 504 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
4 Correct 11 ms 504 KB Output is correct
5 Correct 11 ms 504 KB Output is correct
6 Correct 10 ms 504 KB Output is correct
7 Correct 16 ms 504 KB Output is correct
8 Correct 20 ms 504 KB Output is correct
9 Correct 23 ms 504 KB Output is correct
10 Correct 15 ms 504 KB Output is correct
11 Correct 15 ms 504 KB Output is correct
12 Correct 18 ms 504 KB Output is correct
13 Correct 19 ms 504 KB Output is correct
14 Correct 17 ms 504 KB Output is correct
15 Correct 22 ms 504 KB Output is correct
16 Correct 19 ms 504 KB Output is correct
17 Correct 21 ms 504 KB Output is correct
18 Correct 24 ms 504 KB Output is correct
19 Correct 20 ms 504 KB Output is correct
20 Correct 20 ms 504 KB Output is correct
21 Correct 23 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 504 KB Output is correct
2 Correct 11 ms 504 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
4 Correct 11 ms 504 KB Output is correct
5 Correct 11 ms 504 KB Output is correct
6 Correct 10 ms 504 KB Output is correct
7 Correct 16 ms 504 KB Output is correct
8 Correct 20 ms 504 KB Output is correct
9 Correct 23 ms 504 KB Output is correct
10 Correct 15 ms 504 KB Output is correct
11 Correct 15 ms 504 KB Output is correct
12 Correct 18 ms 504 KB Output is correct
13 Correct 19 ms 504 KB Output is correct
14 Correct 17 ms 504 KB Output is correct
15 Correct 22 ms 504 KB Output is correct
16 Correct 19 ms 504 KB Output is correct
17 Correct 21 ms 504 KB Output is correct
18 Correct 24 ms 504 KB Output is correct
19 Correct 20 ms 504 KB Output is correct
20 Correct 20 ms 504 KB Output is correct
21 Correct 23 ms 504 KB Output is correct
22 Execution timed out 1081 ms 760 KB Time limit exceeded
23 Halted 0 ms 0 KB -