답안 #1007794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007794 2024-06-25T13:30:05 Z bachhoangxuan 웜뱃 (IOI13_wombats) C++17
100 / 100
2385 ms 191804 KB
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e3+5;
const int maxm = 2e2+5;
const int B = 10;
const int maxs = 1030;
const int inf = 1e9;

int R,C,S;
int H[maxn][maxm],V[maxn][maxm];
int tree[maxs][maxm][maxm],opt[maxm];

void init(int x,int id){
    int l=x*B,r=min((x+1)*B,R);
    for(int i=0;i<C;i++) for(int j=0;j<C;j++) tree[id][i][j]=(i!=j)*inf;
    for(int t=l;t<r;t++){
        for(int i=0;i<C;i++){
            for(int j=1;j<C;j++) tree[id][i][j]=min(tree[id][i][j],tree[id][i][j-1]+H[t][j-1]);
            for(int j=C-1;j>0;j--) tree[id][i][j-1]=min(tree[id][i][j-1],tree[id][i][j]+H[t][j-1]);
            for(int j=0;j<C;j++) tree[id][i][j]+=V[t][j];
        }
    }
}
void merge(int id){
    for(int i=0;i<C;i++) opt[i]=0;
    opt[C]=C-1;
    for(int i=0;i<C;i++) for(int j=C-1;j>=0;j--){
        tree[id][i][j]=inf;
        for(int k=opt[j];k<=opt[j+1];k++){
            int val=tree[id<<1][i][k]+tree[id<<1|1][k][j];
            if(val<tree[id][i][j]) tree[id][i][j]=val,opt[j]=k;
        }
    }
}

void build(int l,int r,int id){
    if(l==r) return init(l,id);
    int mid=(l+r)>>1;
    build(l,mid,id<<1);build(mid+1,r,id<<1|1);
    merge(id);
}
void update(int l,int r,int id,int p){
    if(l==r) return init(l,id);
    int mid=(l+r)>>1;
    if(p<=mid) update(l,mid,id<<1,p);
    else update(mid+1,r,id<<1|1,p);
    merge(id);
}

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-1;j++) H[i][j]=_H[i][j];
    for(int i=0;i<R-1;i++) for(int j=0;j<C;j++) V[i][j]=_V[i][j];
    S=(R-1)/B;
    build(0,S,1);
}

void changeH(int P, int Q, int W) {
    H[P][Q]=W;
    update(0,S,1,P/B);
}

void changeV(int P, int Q, int W) {
    V[P][Q]=W;
    update(0,S,1,P/B);
}

int escape(int V1, int V2) {
    return tree[1][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 9 ms 93016 KB Output is correct
2 Correct 12 ms 95068 KB Output is correct
3 Correct 45 ms 96784 KB Output is correct
4 Correct 9 ms 93016 KB Output is correct
5 Correct 12 ms 93040 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8640 KB Output is correct
11 Correct 45 ms 9440 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 12828 KB Output is correct
2 Correct 60 ms 12828 KB Output is correct
3 Correct 63 ms 12636 KB Output is correct
4 Correct 65 ms 12636 KB Output is correct
5 Correct 66 ms 12816 KB Output is correct
6 Correct 0 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Correct 258 ms 12632 KB Output is correct
10 Correct 1 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 104028 KB Output is correct
2 Correct 12 ms 107868 KB Output is correct
3 Correct 10 ms 106076 KB Output is correct
4 Correct 31 ms 106804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 12636 KB Output is correct
2 Correct 58 ms 12636 KB Output is correct
3 Correct 66 ms 12636 KB Output is correct
4 Correct 68 ms 12808 KB Output is correct
5 Correct 61 ms 12636 KB Output is correct
6 Correct 11 ms 101980 KB Output is correct
7 Correct 10 ms 99976 KB Output is correct
8 Correct 11 ms 107868 KB Output is correct
9 Correct 31 ms 106836 KB Output is correct
10 Correct 10 ms 105052 KB Output is correct
11 Correct 10 ms 107136 KB Output is correct
12 Correct 46 ms 108576 KB Output is correct
13 Correct 12 ms 107100 KB Output is correct
14 Correct 10 ms 107012 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 0 ms 4444 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 1 ms 8540 KB Output is correct
21 Correct 1 ms 8540 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 8540 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 39 ms 9512 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 246 ms 12816 KB Output is correct
28 Correct 597 ms 145236 KB Output is correct
29 Correct 603 ms 136532 KB Output is correct
30 Correct 606 ms 135504 KB Output is correct
31 Correct 626 ms 145492 KB Output is correct
32 Correct 1 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12636 KB Output is correct
2 Correct 60 ms 12636 KB Output is correct
3 Correct 62 ms 12632 KB Output is correct
4 Correct 63 ms 12632 KB Output is correct
5 Correct 70 ms 12636 KB Output is correct
6 Correct 11 ms 106076 KB Output is correct
7 Correct 11 ms 107868 KB Output is correct
8 Correct 11 ms 106072 KB Output is correct
9 Correct 31 ms 106832 KB Output is correct
10 Correct 10 ms 107096 KB Output is correct
11 Correct 10 ms 107024 KB Output is correct
12 Correct 44 ms 106580 KB Output is correct
13 Correct 10 ms 107100 KB Output is correct
14 Correct 10 ms 105072 KB Output is correct
15 Correct 979 ms 182960 KB Output is correct
16 Correct 2385 ms 185168 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 8540 KB Output is correct
21 Correct 1 ms 8540 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 8540 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 1 ms 8540 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 40 ms 10844 KB Output is correct
28 Correct 1 ms 8536 KB Output is correct
29 Correct 286 ms 12904 KB Output is correct
30 Correct 600 ms 149076 KB Output is correct
31 Correct 2221 ms 191300 KB Output is correct
32 Correct 2180 ms 191356 KB Output is correct
33 Correct 598 ms 141392 KB Output is correct
34 Correct 2125 ms 174684 KB Output is correct
35 Correct 613 ms 142812 KB Output is correct
36 Correct 2251 ms 173500 KB Output is correct
37 Correct 638 ms 150864 KB Output is correct
38 Correct 2219 ms 191804 KB Output is correct
39 Correct 1 ms 8540 KB Output is correct
40 Correct 2282 ms 173876 KB Output is correct