답안 #587137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587137 2022-07-01T11:26:17 Z usuyus 웜뱃 (IOI13_wombats) C++14
55 / 100
20000 ms 19436 KB
#include "wombats.h"

#include <bits/stdc++.h>
using namespace std;

int R, C, H[5000][200], V[5000][200];
int ans[200][200];
bool calced[200];

void init(int _R, int _C, int _H[5000][200], int _V[5000][200]) {
    R = _R, C = _C;

    for (int i=0; i<R; i++) {
        for (int j=0; j<C; j++) {
            H[i][j] = _H[i][j];
            V[i][j] = _V[i][j];
        }
    }

    for (int i=0; i<C; i++) calced[i] = false;
}

void changeH(int P, int Q, int W) {
    H[P][Q] = W;
    for (int i=0; i<C; i++) calced[i] = false;
}

void changeV(int P, int Q, int W) {
    V[P][Q] = W;
    for (int i=0; i<C; i++) calced[i] = false;
}

void calc_ans(int S) {
    int dp[200], lft[200], rgt[200];

    dp[S] = 0;
    for (int i=S+1; i<C;  i++) dp[i] = dp[i-1] + H[0][i-1];
    for (int i=S-1; i>=0; i--) dp[i] = dp[i+1] + H[0][i];
    for (int i=0; i<C; i++) dp[i] += V[0][i];

    for (int i=1; i<R; i++) {

        lft[0] = dp[0];
        for (int j=1; j<C; j++) {
            lft[j] = min(dp[j], lft[j-1] + H[i][j-1]);
        }

        rgt[C-1] = dp[C-1];
        for (int j=C-2; j>=0; j--) {
            rgt[j] = min(dp[j], rgt[j+1] + H[i][j]);
        }

        for (int j=0; j<C; j++) {
            dp[j] = min(lft[j], rgt[j]) + V[i][j];
        }
    }

    for (int i=0; i<C; i++) ans[S][i] = dp[i];
    calced[S] = true;
}

int escape(int V1, int V2) {
    if (!calced[V1]) calc_ans(V1);
    return ans[V1][V2];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 11988 KB Output is correct
2 Correct 24 ms 12096 KB Output is correct
3 Correct 85 ms 14804 KB Output is correct
4 Correct 21 ms 12096 KB Output is correct
5 Correct 21 ms 11988 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 76 ms 2716 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 800 KB Output is correct
2 Correct 8 ms 724 KB Output is correct
3 Correct 8 ms 724 KB Output is correct
4 Correct 9 ms 724 KB Output is correct
5 Correct 9 ms 764 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 5 ms 708 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 16056 KB Output is correct
2 Correct 57 ms 15956 KB Output is correct
3 Correct 53 ms 16020 KB Output is correct
4 Correct 85 ms 17384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 724 KB Output is correct
2 Correct 9 ms 724 KB Output is correct
3 Correct 8 ms 788 KB Output is correct
4 Correct 8 ms 724 KB Output is correct
5 Correct 8 ms 724 KB Output is correct
6 Correct 55 ms 16028 KB Output is correct
7 Correct 52 ms 15996 KB Output is correct
8 Correct 69 ms 16024 KB Output is correct
9 Correct 91 ms 17324 KB Output is correct
10 Correct 21 ms 12076 KB Output is correct
11 Correct 21 ms 12088 KB Output is correct
12 Correct 85 ms 14832 KB Output is correct
13 Correct 25 ms 12108 KB Output is correct
14 Correct 22 ms 11988 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 63 ms 2700 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 6 ms 844 KB Output is correct
28 Execution timed out 20062 ms 18536 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 804 KB Output is correct
2 Correct 8 ms 724 KB Output is correct
3 Correct 8 ms 704 KB Output is correct
4 Correct 8 ms 724 KB Output is correct
5 Correct 8 ms 724 KB Output is correct
6 Correct 52 ms 16020 KB Output is correct
7 Correct 53 ms 15956 KB Output is correct
8 Correct 53 ms 15940 KB Output is correct
9 Correct 84 ms 17300 KB Output is correct
10 Correct 21 ms 11988 KB Output is correct
11 Correct 23 ms 11972 KB Output is correct
12 Correct 85 ms 14776 KB Output is correct
13 Correct 21 ms 11988 KB Output is correct
14 Correct 21 ms 11988 KB Output is correct
15 Correct 188 ms 18384 KB Output is correct
16 Execution timed out 20028 ms 19436 KB Time limit exceeded
17 Halted 0 ms 0 KB -