답안 #533605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533605 2022-03-06T15:37:44 Z ddy888 Nautilus (BOI19_nautilus) C++17
66 / 100
33 ms 40644 KB
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long 
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;  
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
// O(RCM)
int R, C, M, dp[510][510][510], ans;
char A[510][510], ops[510];

inline void chmax(int &x, int y) {
    x = max(x, y);
}

int check(int i, int j, int idx) {
    if (i > R || j > C) return 0;
    if (A[i][j] == '#') return 0;
    if (idx == 0) return 1;
    return dp[i][j][idx];
}

signed main() {
    fast;
    cin >> R >> C >> M;
    assert(M <= 100);
    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) cin >> A[i][j];
    }
    for (int i = 1; i <= M; ++i) cin >> ops[i];
    for (int k = 1; k <= M; ++k) {
        for (int i = 1; i <= R; ++i) {
            for (int j = 1; j <= C; ++j) {
                if (A[i][j] == '#') continue;
                if (ops[k] == 'N' || ops[k] == '?') chmax(dp[i][j][k], check(i + 1, j, k - 1));
                if (ops[k] == 'E' || ops[k] == '?') chmax(dp[i][j][k], check(i, j - 1, k - 1));
                if (ops[k] == 'W' || ops[k] == '?') chmax(dp[i][j][k], check(i, j + 1, k - 1));
                if (ops[k] == 'S' || ops[k] == '?') chmax(dp[i][j][k], check(i - 1, j, k - 1));
                // debug(dp[i][j][k], i, j, k);
            }
        }
    }
    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) {
            // if (A[i][j] == '#') cout << '#';
            // else cout << dp[i][j][M];
            ans += dp[i][j][M];
        }
        // cout << '\n';
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 40644 KB Output is correct
2 Correct 27 ms 33696 KB Output is correct
3 Correct 25 ms 26624 KB Output is correct
4 Correct 20 ms 18864 KB Output is correct
5 Correct 14 ms 10188 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 40644 KB Output is correct
2 Correct 27 ms 33696 KB Output is correct
3 Correct 25 ms 26624 KB Output is correct
4 Correct 20 ms 18864 KB Output is correct
5 Correct 14 ms 10188 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 33 ms 40604 KB Output is correct
8 Correct 30 ms 26464 KB Output is correct
9 Correct 23 ms 18824 KB Output is correct
10 Correct 14 ms 10192 KB Output is correct
11 Correct 7 ms 844 KB Output is correct
12 Correct 33 ms 40644 KB Output is correct
13 Correct 30 ms 34116 KB Output is correct
14 Correct 29 ms 26432 KB Output is correct
15 Correct 14 ms 10264 KB Output is correct
16 Correct 6 ms 948 KB Output is correct
17 Correct 32 ms 40644 KB Output is correct
18 Correct 31 ms 34128 KB Output is correct
19 Correct 24 ms 18804 KB Output is correct
20 Correct 15 ms 10188 KB Output is correct
21 Correct 9 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 40644 KB Output is correct
2 Correct 27 ms 33696 KB Output is correct
3 Correct 25 ms 26624 KB Output is correct
4 Correct 20 ms 18864 KB Output is correct
5 Correct 14 ms 10188 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 33 ms 40604 KB Output is correct
8 Correct 30 ms 26464 KB Output is correct
9 Correct 23 ms 18824 KB Output is correct
10 Correct 14 ms 10192 KB Output is correct
11 Correct 7 ms 844 KB Output is correct
12 Correct 33 ms 40644 KB Output is correct
13 Correct 30 ms 34116 KB Output is correct
14 Correct 29 ms 26432 KB Output is correct
15 Correct 14 ms 10264 KB Output is correct
16 Correct 6 ms 948 KB Output is correct
17 Correct 32 ms 40644 KB Output is correct
18 Correct 31 ms 34128 KB Output is correct
19 Correct 24 ms 18804 KB Output is correct
20 Correct 15 ms 10188 KB Output is correct
21 Correct 9 ms 972 KB Output is correct
22 Runtime error 15 ms 332 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -