Submission #889228

# Submission time Handle Problem Language Result Execution time Memory
889228 2023-12-19T08:22:36 Z abcvuitunggio Wombats (IOI13_wombats) C++17
100 / 100
7125 ms 108696 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
const int sz=20,INF=2e9;
int r,c,row,h[5000][200],v[5000][200],st[20000/sz+5][200][200];
void dnc(int node, int l, int r, int i, int optl, int optr){
    if (l>r)
        return;
    int mid=(l+r)>>1;
    pair <int, int> p={INF,-1};
    for (int j=optl;j<=optr;j++)
        p=min(p,{st[node<<1][i][j]+st[node<<1|1][j][mid],j});
    st[node][i][mid]=p.first;
    dnc(node,l,mid-1,i,optl,p.second);
    dnc(node,mid+1,r,i,p.second,optr);
}
void update(int node, int l, int r, int x, int y){
    if (l>y||r<x)
        return;
    if (l==r){
        for (int i=0;i<c;i++)
            for (int j=0;j<c;j++)
                st[node][i][j]=(i==j?0:INF);
        for (int k=l*sz;k<min(l*sz+sz,row);k++){
            for (int i=0;i<c;i++){
                for (int j=1;j<c;j++)
                    st[node][i][j]=min(st[node][i][j],st[node][i][j-1]+h[k][j-1]);
                for (int j=c-2;j>=0;j--)
                    st[node][i][j]=min(st[node][i][j],st[node][i][j+1]+h[k][j]);
                for (int j=0;j<c;j++)
                    st[node][i][j]+=v[k][j];
            }
        }
        return;
    }
    int mid=(l+r)>>1;
    update(node<<1,l,mid,x,y);
    update(node<<1|1,mid+1,r,x,y);
    for (int i=0;i<c;i++)
        dnc(node,0,c-1,i,0,c-1);
}
void init(int R, int C, int H[5000][200], int V[5000][200]){
    row=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];
    update(1,0,(r-1)/sz,0,r-1);
}
void changeH(int P, int Q, int W){
    h[P][Q]=W;
    update(1,0,(r-1)/sz,P/sz,P/sz);
}
void changeV(int P, int Q, int W){
    v[P][Q]=W;
    update(1,0,(r-1)/sz,P/sz,P/sz);
}
int escape(int V1, int V2){
    return st[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;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 16 ms 92760 KB Output is correct
2 Correct 10 ms 93016 KB Output is correct
3 Correct 60 ms 95580 KB Output is correct
4 Correct 11 ms 92764 KB Output is correct
5 Correct 10 ms 92872 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory 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 8540 KB Output is correct
6 Correct 2 ms 8536 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 53 ms 9424 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 10588 KB Output is correct
2 Correct 191 ms 10840 KB Output is correct
3 Correct 194 ms 11092 KB Output is correct
4 Correct 193 ms 10844 KB Output is correct
5 Correct 194 ms 10844 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 939 ms 11100 KB Output is correct
10 Correct 3 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 97372 KB Output is correct
2 Correct 12 ms 97368 KB Output is correct
3 Correct 12 ms 97372 KB Output is correct
4 Correct 39 ms 98920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 10588 KB Output is correct
2 Correct 189 ms 11248 KB Output is correct
3 Correct 192 ms 10840 KB Output is correct
4 Correct 191 ms 10840 KB Output is correct
5 Correct 195 ms 10844 KB Output is correct
6 Correct 14 ms 97372 KB Output is correct
7 Correct 11 ms 97372 KB Output is correct
8 Correct 11 ms 97372 KB Output is correct
9 Correct 39 ms 98896 KB Output is correct
10 Correct 10 ms 92760 KB Output is correct
11 Correct 11 ms 92960 KB Output is correct
12 Correct 62 ms 95504 KB Output is correct
13 Correct 10 ms 92760 KB Output is correct
14 Correct 10 ms 92792 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 8636 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 8640 KB Output is correct
23 Correct 1 ms 8636 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 54 ms 10796 KB Output is correct
26 Correct 2 ms 8536 KB Output is correct
27 Correct 964 ms 10844 KB Output is correct
28 Correct 1749 ms 101972 KB Output is correct
29 Correct 1693 ms 101204 KB Output is correct
30 Correct 1694 ms 100876 KB Output is correct
31 Correct 1806 ms 103212 KB Output is correct
32 Correct 1 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 181 ms 10588 KB Output is correct
2 Correct 189 ms 10840 KB Output is correct
3 Correct 192 ms 10844 KB Output is correct
4 Correct 188 ms 10856 KB Output is correct
5 Correct 199 ms 10852 KB Output is correct
6 Correct 12 ms 97368 KB Output is correct
7 Correct 13 ms 97368 KB Output is correct
8 Correct 12 ms 97372 KB Output is correct
9 Correct 41 ms 98900 KB Output is correct
10 Correct 10 ms 92764 KB Output is correct
11 Correct 10 ms 92764 KB Output is correct
12 Correct 63 ms 95648 KB Output is correct
13 Correct 10 ms 92760 KB Output is correct
14 Correct 10 ms 92760 KB Output is correct
15 Correct 1795 ms 107448 KB Output is correct
16 Correct 7110 ms 108696 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 4440 KB Output is correct
20 Correct 1 ms 8536 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 2 ms 8536 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 55 ms 10956 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 960 ms 10840 KB Output is correct
30 Correct 1797 ms 101460 KB Output is correct
31 Correct 6994 ms 105780 KB Output is correct
32 Correct 6920 ms 105704 KB Output is correct
33 Correct 1722 ms 100692 KB Output is correct
34 Correct 6925 ms 105156 KB Output is correct
35 Correct 1750 ms 100840 KB Output is correct
36 Correct 6966 ms 104848 KB Output is correct
37 Correct 1802 ms 103272 KB Output is correct
38 Correct 7029 ms 106332 KB Output is correct
39 Correct 1 ms 8540 KB Output is correct
40 Correct 7125 ms 105176 KB Output is correct