답안 #420519

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420519 2021-06-08T12:16:10 Z arayi 웜뱃 (IOI13_wombats) C++17
55 / 100
20000 ms 41416 KB
#include "wombats.h"
#include <bits/stdc++.h>
#define lli long long
using namespace std;


int n, m;
lli h[5002][201], v[5002][201];
lli dp[5002][201], pr[201];
void upd(int v1)
{
    for(int i = 0; i < m; i++) dp[n - 1][i] = 1e17;
    dp[n - 1][v1] = 0;
    for(int i = n - 2; i >= 0; i--)
    {
        pr[0] = 0;
        for(int j = 0; j < m - 1; j++)
            pr[j + 1] = pr[j] + h[i + 1][j];
        lli mn = dp[i + 1][0] + pr[m - 1];
        for(int j = 0; j < m; j++)
        {
            mn = min(mn, dp[i + 1][j] + pr[m - 1] - pr[j]);
            dp[i][j] = mn - (pr[m - 1] - pr[j]) + v[i][j];
        }
        mn = dp[i + 1][m - 1] + pr[m - 1];
        for(int j = m - 1; j >= 0; j--)
        {
            mn = min(mn, dp[i + 1][j] + pr[j]);
            dp[i][j] = min(dp[i][j], mn - pr[j] + v[i][j]);
        }
    }
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n = R; m = C;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++) h[i][j] = H[i][j], v[i][j]= V[i][j];
}

void changeH(int P, int Q, int W) {
    h[P][Q] = W;
}

void changeV(int P, int Q, int W) {
    v[P][Q] = W;
}

int escape(int V1, int V2) {
    upd(V2);
    lli mn = dp[0][V1], sm = 0;
    for(int i = V1; i < m - 1; i++)
    {
        sm += h[0][i];
        mn = min(mn, dp[0][i + 1] + sm);
    }
    sm = 0;
    for(int i = V1 - 1; i >= 0; i--)
    {
        sm += h[0][i];
        mn = min(mn, dp[0][i] + sm);
    }
    return mn;
}

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 63 ms 27856 KB Output is correct
2 Correct 53 ms 27836 KB Output is correct
3 Correct 19728 ms 30524 KB Output is correct
4 Correct 64 ms 27824 KB Output is correct
5 Correct 64 ms 27836 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 501 ms 2768 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 972 KB Output is correct
2 Correct 10 ms 956 KB Output is correct
3 Correct 11 ms 956 KB Output is correct
4 Correct 11 ms 1040 KB Output is correct
5 Correct 8 ms 972 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 8 ms 972 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 31780 KB Output is correct
2 Correct 169 ms 31772 KB Output is correct
3 Correct 145 ms 31792 KB Output is correct
4 Correct 12021 ms 33060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 972 KB Output is correct
2 Correct 7 ms 972 KB Output is correct
3 Correct 8 ms 1036 KB Output is correct
4 Correct 8 ms 1036 KB Output is correct
5 Correct 7 ms 1040 KB Output is correct
6 Correct 157 ms 31756 KB Output is correct
7 Correct 160 ms 31768 KB Output is correct
8 Correct 155 ms 31788 KB Output is correct
9 Correct 13411 ms 33284 KB Output is correct
10 Correct 66 ms 27836 KB Output is correct
11 Correct 65 ms 27852 KB Output is correct
12 Correct 19427 ms 30704 KB Output is correct
13 Correct 65 ms 27852 KB Output is correct
14 Correct 62 ms 27852 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 436 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 468 ms 2756 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 8 ms 1032 KB Output is correct
28 Execution timed out 20051 ms 35556 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 972 KB Output is correct
2 Correct 8 ms 1020 KB Output is correct
3 Correct 8 ms 992 KB Output is correct
4 Correct 8 ms 972 KB Output is correct
5 Correct 7 ms 972 KB Output is correct
6 Correct 159 ms 31692 KB Output is correct
7 Correct 160 ms 31780 KB Output is correct
8 Correct 150 ms 31684 KB Output is correct
9 Correct 14041 ms 33160 KB Output is correct
10 Correct 50 ms 27828 KB Output is correct
11 Correct 53 ms 27736 KB Output is correct
12 Correct 19579 ms 30840 KB Output is correct
13 Correct 63 ms 27852 KB Output is correct
14 Correct 62 ms 27848 KB Output is correct
15 Correct 264 ms 41416 KB Output is correct
16 Execution timed out 20055 ms 39636 KB Time limit exceeded
17 Halted 0 ms 0 KB -