답안 #286452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286452 2020-08-30T12:23:01 Z evpipis 웜뱃 (IOI13_wombats) C++11
39 / 100
20000 ms 25976 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;

const int len_n = 5005, len_m = 205, inf = 1e9+10;
int hor[len_n][len_m], ver[len_n][len_m], n, m, k;

struct{
    struct node{
        int to[len_m][len_m];

        node(){
            for (int a = 0; a < m; a++)
                for (int b = 0; b < m; b++)
                    to[a][b] = inf; // check this
        }

        node(int i){
            for (int a = 0, suma = 0; a < m; a++){
                for (int b = 0, dif = suma; b < m; b++){
                    to[a][b] = dif + ver[i][b];

                    if (b < a)
                        dif -= hor[i][b];
                    else
                        dif += hor[i][b];
                }

                suma += hor[i][a];
            }

            if (0){
            printf("-------------------------------------------\n");
            printf("just constructed %d-th leaf\n", i);
            for (int a = 0; a < m; a++){
                for (int b = 0; b < m; b++)
                    printf("%d ", to[a][b]);
                printf("\n");
            }
            printf("-------------------------------------------\n");
            }
        }
    };

    node buck[75], root;

    node join(node fir, node sec){
        node res;

        for (int a = 0; a < m; a++)
            for (int b = 0; b < m; b++)
                for (int c = 0; c < m; c++)
                    res.to[a][b] = min(res.to[a][b], fir.to[a][c]+sec.to[c][b]);

        return res;
    }

    void upd_buck(int b){
        int st = b*k, en = min(n, (b+1)*k);

        buck[b] = node(st);
        for (int i = st+1; i < en; i++)
            buck[b] = join(buck[b], node(i));
    }

    void upd_root(){
        root = buck[0];
        for (int b = 1; b*k < n; b++)
            root = join(root, buck[b]);
    }

    int ask(int a, int b){
        return root.to[a][b];
    }
} data;

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-1; j++)
            hor[i][j] = H[i][j];
    for (int i = 0; i < n-1; i++)
        for (int j = 0; j < m; j++)
            ver[i][j] = V[i][j];

    k = sqrt(n*m);
    for (int b = 0; k*b < n; b++)
        data.upd_buck(b);
    data.upd_root();
}

void changeH(int P, int Q, int W) {
    hor[P][Q] = W;
    data.upd_buck(P/k);
    data.upd_root();
}

void changeV(int P, int Q, int W) {
    ver[P][Q] = W;
    data.upd_buck(P/k);
    data.upd_root();
}

int escape(int V1, int V2) {
    return data.ask(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 2866 ms 20928 KB Output is correct
2 Correct 2873 ms 20856 KB Output is correct
3 Correct 2982 ms 22416 KB Output is correct
4 Correct 2888 ms 20856 KB Output is correct
5 Correct 2904 ms 20856 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 2 ms 1152 KB Output is correct
6 Correct 2 ms 1152 KB Output is correct
7 Correct 2 ms 1152 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
9 Correct 2 ms 1152 KB Output is correct
10 Correct 2 ms 1408 KB Output is correct
11 Correct 94 ms 2168 KB Output is correct
12 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12550 ms 1628 KB Output is correct
2 Correct 12418 ms 1544 KB Output is correct
3 Correct 12867 ms 1548 KB Output is correct
4 Correct 12699 ms 1544 KB Output is correct
5 Correct 12382 ms 1792 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1152 KB Output is correct
9 Execution timed out 20079 ms 1528 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2963 ms 25208 KB Output is correct
2 Correct 3007 ms 25080 KB Output is correct
3 Correct 3019 ms 25080 KB Output is correct
4 Correct 3043 ms 25848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12684 ms 1544 KB Output is correct
2 Correct 12272 ms 1656 KB Output is correct
3 Correct 12800 ms 1548 KB Output is correct
4 Correct 12876 ms 1504 KB Output is correct
5 Correct 12394 ms 1788 KB Output is correct
6 Correct 3011 ms 25336 KB Output is correct
7 Correct 3037 ms 25208 KB Output is correct
8 Correct 3150 ms 25116 KB Output is correct
9 Correct 3094 ms 25960 KB Output is correct
10 Correct 2918 ms 20728 KB Output is correct
11 Correct 2886 ms 20728 KB Output is correct
12 Correct 2979 ms 22364 KB Output is correct
13 Correct 2867 ms 20820 KB Output is correct
14 Correct 2901 ms 20824 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 2 ms 1152 KB Output is correct
20 Correct 3 ms 1152 KB Output is correct
21 Correct 2 ms 1152 KB Output is correct
22 Correct 2 ms 1152 KB Output is correct
23 Correct 2 ms 1152 KB Output is correct
24 Correct 2 ms 1408 KB Output is correct
25 Correct 89 ms 2168 KB Output is correct
26 Correct 2 ms 1152 KB Output is correct
27 Execution timed out 20074 ms 1528 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12716 ms 1656 KB Output is correct
2 Correct 12308 ms 1532 KB Output is correct
3 Correct 12632 ms 1552 KB Output is correct
4 Correct 12623 ms 1572 KB Output is correct
5 Correct 12346 ms 1784 KB Output is correct
6 Correct 2979 ms 25464 KB Output is correct
7 Correct 3027 ms 25128 KB Output is correct
8 Correct 2984 ms 25080 KB Output is correct
9 Correct 3086 ms 25976 KB Output is correct
10 Correct 2910 ms 20856 KB Output is correct
11 Correct 2876 ms 20856 KB Output is correct
12 Correct 2949 ms 22392 KB Output is correct
13 Correct 2899 ms 20856 KB Output is correct
14 Correct 2870 ms 20728 KB Output is correct
15 Execution timed out 20099 ms 17300 KB Time limit exceeded
16 Halted 0 ms 0 KB -