답안 #286422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286422 2020-08-30T11:31:30 Z evpipis 웜뱃 (IOI13_wombats) C++11
27 / 100
20000 ms 30184 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; a < m; a++)
                for (int b = 0; b < m; b++)
                    to[a][b] = inf; // check this

            for (int a = 0; a < m; a++){
                for (int b = a, sum = 0; b < m; b++){
                    //printf("a = %d, b = %d, sum = %d\n", a, b, sum);

                    for (int c = a, cur = sum; c <= b; c++){
                        //printf("c = %d, cur = %d\n", c, cur);

                        to[a][b] = min(to[a][b], cur+ver[i][c]);
                        cur += hor[i][c]-hor[i+1][c];
                    }

                    sum += hor[i+1][b];
                }
            }

            for (int a = 0; a < m; a++){
                for (int b = a, sum = 0; b >= 0; b--){
                    //printf("a = %d, b = %d, sum = %d\n", a, b, sum);

                    for (int c = a, cur = sum; c >= b; c--){
                        //printf("c = %d, cur = %d\n", c, cur);

                        to[a][b] = min(to[a][b], cur+ver[i][c]);

                        if (c > 0)
                            cur += hor[i][c-1]-hor[i+1][c-1];
                    }

                    if (b > 0)
                        sum += hor[i+1][b-1];
                }
            }

            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-1, (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-1; 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 = 70; //sqrt(n);
    for (int b = 0; k*b < n-1; b++)
        data.upd_buck(b);
    data.upd_root();
}

void changeH(int P, int Q, int W) {
    hor[P][Q] = W;
    if (P > 0)
        data.upd_buck((P-1)/k);
    if (P < n-1)
        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 2956 ms 20836 KB Output is correct
2 Correct 2979 ms 20848 KB Output is correct
3 Correct 2945 ms 23624 KB Output is correct
4 Correct 2947 ms 20852 KB Output is correct
5 Correct 2921 ms 20848 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 1 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 2 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 Incorrect 2 ms 1152 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7966 ms 1868 KB Output is correct
2 Correct 12480 ms 1856 KB Output is correct
3 Execution timed out 20051 ms 1876 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3669 ms 28820 KB Output is correct
2 Correct 3054 ms 28792 KB Output is correct
3 Correct 3640 ms 28796 KB Output is correct
4 Correct 3564 ms 30184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7463 ms 2036 KB Output is correct
2 Correct 11983 ms 1912 KB Output is correct
3 Execution timed out 20052 ms 1784 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7587 ms 1864 KB Output is correct
2 Correct 12125 ms 1956 KB Output is correct
3 Execution timed out 20026 ms 1916 KB Time limit exceeded
4 Halted 0 ms 0 KB -