답안 #489145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
489145 2021-11-21T09:33:21 Z ak2006 Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 972 KB
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int main()
{
    fast;

    int r,c,m;
    cin>>r>>c>>m;
    char g[r + 1][c + 1];
    bool dp[r + 2][c + 2][2];
    memset(dp,false,sizeof(dp));
    for (int i = 1;i<=r;i++)
        for (int j = 1;j<=c;j++)
            cin>>g[i][j],dp[i][j][0] = (g[i][j] != '#');
    string s;
    cin>>s;
    int ans = 0;
    for (int t = 1;t<=m;t++){
        for (int i = 1;i<=r;i++){
            for (int j = 1;j<=c;j++){
                if (g[i][j] == '#')continue;
                if (s[t - 1] == 'E')
                    dp[i][j][t&1] = dp[i][j - 1][(t - 1)&1];
                else if (s[t - 1] == 'W')
                    dp[i][j][t&1] = dp[i][j + 1][(t - 1)&1];
                else if (s[t - 1] == 'N')
                    dp[i][j][t&1] = dp[i + 1][j][(t - 1)&1];
                else if (s[t - 1] == 'S')
                    dp[i][j][t&1] = dp[i - 1][j][(t - 1)&1];
                else dp[i][j][t&1] = dp[i - 1][j][(t - 1)&1] or 
                    dp[i + 1][j][(t - 1)&1] or
                dp[i][j + 1][(t - 1)&1] or dp[i][j - 1][(t - 1)&1];
                if (t == m)
                    ans += dp[i][j][t&1];
            }
        }
    }
    cout<<ans;
    return 0;
}

Compilation message

nautilus.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
nautilus.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 6 ms 336 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 6 ms 336 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 7 ms 332 KB Output is correct
9 Correct 6 ms 332 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 6 ms 336 KB Output is correct
14 Correct 8 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 6 ms 332 KB Output is correct
19 Correct 7 ms 340 KB Output is correct
20 Correct 4 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 6 ms 336 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 7 ms 332 KB Output is correct
9 Correct 6 ms 332 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 6 ms 336 KB Output is correct
14 Correct 8 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 6 ms 332 KB Output is correct
19 Correct 7 ms 340 KB Output is correct
20 Correct 4 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Execution timed out 1092 ms 972 KB Time limit exceeded
23 Halted 0 ms 0 KB -