Submission #1023852

# Submission time Handle Problem Language Result Execution time Memory
1023852 2024-07-15T07:52:51 Z vjudge1 Wombats (IOI13_wombats) C++17
55 / 100
12261 ms 31304 KB
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
int tmp[200][200],SSZZ;
int opt[201][201];
struct matrix{
    int V[200][200];
    void friend operator *=(matrix &a,matrix &b){
        memcpy(tmp,a.V,sizeof tmp);
        for(int i=0;i<SSZZ;i++)
            for(int j=0;j<SSZZ;j++)
                a.V[i][j]=1e9;
        for(int i=0;i<SSZZ;i++)
            opt[SSZZ][i]=SSZZ-1;
        for(int i=SSZZ;i--;) {
            for(int k=0;k<=opt[i+1][0];k++)
                if(a.V[i][0]>tmp[i][k]+b.V[k][0])
                    a.V[i][0]=tmp[i][k]+b.V[k][0],opt[i][0]=k;
            for(int j=1;j<SSZZ;j++)
                for(int k=opt[i][j-1];k<=opt[i+1][j];k++)
                    if(a.V[i][j]>tmp[i][k]+b.V[k][j])
                        a.V[i][j]=tmp[i][k]+b.V[k][j],opt[i][j]=k;
        }
    }
    void reset(){
        for(int i=0;i<200;i++)
            memset(V[i],15,sizeof V[i]),V[i][i]=0;
    }
} mygod[51],finalstuff;
int ans[200][200],lr[5000][200],dn[5000][200],col,row,SZ=210,blocknum;
void recalcblok(int blok){
    mygod[blok].reset();
    int end=min(row-1,SZ*blok+SZ);
    for(int r=SZ*blok+1;r<=end;r++){
        for(int i=0;i<col;i++) {
            for(int j=0;j<col;j++)
                mygod[blok].V[i][j]+=dn[r-1][j];
            for(int j=0;++j<col;)
                mygod[blok].V[i][j]=min(mygod[blok].V[i][j],
                        mygod[blok].V[i][j-1]+lr[r][j-1]);
            for(int j=col;--j;)
                mygod[blok].V[i][j-1]=min(mygod[blok].V[i][j-1],
                            mygod[blok].V[i][j]+lr[r][j-1]);
        }
    }
}
void redofinale(){
    int pref[200];
    pref[0]=0;
    for(int i=1;i<200;i++)
        pref[i]=pref[i-1]+lr[0][i-1];
    for(int i=0;i<col;i++) for(int j=0;j<col;j++)
        finalstuff.V[i][j]=abs(pref[i]-pref[j]);
    for(int i=0;i<=blocknum;i++)
        finalstuff*=mygod[i];
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    SSZZ=C;
    for(int i=0;i<5000;i++)
        memcpy(lr[i],H[i],sizeof lr[i]),
        memcpy(dn[i],V[i],sizeof dn[i]);
    row=R;col=C;
    blocknum=(R-2)/SZ;
    for(int i=0;i<=blocknum;i++)
        recalcblok(i);
    redofinale();
}
void changeH(int P, int Q, int W) {
    lr[P][Q]=W;
    if(P)recalcblok(P/SZ),redofinale();
}

void changeV(int P, int Q, int W) {
    memset(ans,-1,sizeof ans);
    dn[P][Q]=W;
    recalcblok(P/SZ),redofinale();
}
int escape(int V1, int V2) {
    return finalstuff.V[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;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 58 ms 16252 KB Output is correct
2 Correct 57 ms 16216 KB Output is correct
3 Correct 92 ms 17748 KB Output is correct
4 Correct 57 ms 16220 KB Output is correct
5 Correct 56 ms 16220 KB Output is correct
6 Correct 4 ms 8536 KB Output is correct
7 Correct 4 ms 8536 KB Output is correct
8 Correct 5 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Correct 4 ms 8536 KB Output is correct
3 Correct 3 ms 8540 KB Output is correct
4 Correct 4 ms 8540 KB Output is correct
5 Correct 4 ms 8540 KB Output is correct
6 Correct 4 ms 8540 KB Output is correct
7 Correct 4 ms 8468 KB Output is correct
8 Correct 4 ms 8540 KB Output is correct
9 Correct 4 ms 8540 KB Output is correct
10 Correct 4 ms 8540 KB Output is correct
11 Correct 42 ms 9468 KB Output is correct
12 Correct 4 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 9056 KB Output is correct
2 Correct 265 ms 9048 KB Output is correct
3 Correct 265 ms 8912 KB Output is correct
4 Correct 278 ms 9300 KB Output is correct
5 Correct 272 ms 9064 KB Output is correct
6 Correct 4 ms 8536 KB Output is correct
7 Correct 4 ms 8536 KB Output is correct
8 Correct 3 ms 8512 KB Output is correct
9 Correct 1246 ms 9060 KB Output is correct
10 Correct 4 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 20060 KB Output is correct
2 Correct 57 ms 20060 KB Output is correct
3 Correct 56 ms 20056 KB Output is correct
4 Correct 78 ms 20964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 267 ms 9048 KB Output is correct
2 Correct 270 ms 9296 KB Output is correct
3 Correct 271 ms 8792 KB Output is correct
4 Correct 273 ms 9052 KB Output is correct
5 Correct 273 ms 9076 KB Output is correct
6 Correct 59 ms 20060 KB Output is correct
7 Correct 57 ms 20216 KB Output is correct
8 Correct 57 ms 20056 KB Output is correct
9 Correct 92 ms 21404 KB Output is correct
10 Correct 53 ms 16220 KB Output is correct
11 Correct 53 ms 16220 KB Output is correct
12 Correct 88 ms 18516 KB Output is correct
13 Correct 54 ms 16216 KB Output is correct
14 Correct 54 ms 16216 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 4 ms 8536 KB Output is correct
17 Correct 5 ms 8540 KB Output is correct
18 Correct 4 ms 8540 KB Output is correct
19 Correct 4 ms 8540 KB Output is correct
20 Correct 4 ms 8540 KB Output is correct
21 Correct 4 ms 8640 KB Output is correct
22 Correct 5 ms 8540 KB Output is correct
23 Correct 4 ms 8540 KB Output is correct
24 Correct 4 ms 8540 KB Output is correct
25 Correct 88 ms 10636 KB Output is correct
26 Correct 4 ms 8540 KB Output is correct
27 Correct 1270 ms 8944 KB Output is correct
28 Incorrect 3552 ms 22716 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 270 ms 9136 KB Output is correct
2 Correct 275 ms 9052 KB Output is correct
3 Correct 294 ms 8796 KB Output is correct
4 Correct 271 ms 9052 KB Output is correct
5 Correct 255 ms 8952 KB Output is correct
6 Correct 61 ms 20252 KB Output is correct
7 Correct 66 ms 20220 KB Output is correct
8 Correct 61 ms 20056 KB Output is correct
9 Correct 82 ms 21332 KB Output is correct
10 Correct 56 ms 16220 KB Output is correct
11 Correct 59 ms 16292 KB Output is correct
12 Correct 95 ms 18512 KB Output is correct
13 Correct 58 ms 16220 KB Output is correct
14 Correct 60 ms 16216 KB Output is correct
15 Correct 782 ms 25564 KB Output is correct
16 Correct 12261 ms 31304 KB Output is correct
17 Correct 4 ms 8540 KB Output is correct
18 Correct 4 ms 8540 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 4 ms 8676 KB Output is correct
21 Correct 5 ms 8540 KB Output is correct
22 Correct 4 ms 8540 KB Output is correct
23 Correct 4 ms 8540 KB Output is correct
24 Correct 5 ms 8540 KB Output is correct
25 Correct 4 ms 8696 KB Output is correct
26 Correct 4 ms 8540 KB Output is correct
27 Correct 43 ms 11036 KB Output is correct
28 Correct 5 ms 8536 KB Output is correct
29 Correct 1254 ms 9140 KB Output is correct
30 Incorrect 3304 ms 24344 KB Output isn't correct
31 Halted 0 ms 0 KB -