답안 #889227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889227 2023-12-19T08:19:26 Z abcvuitunggio 웜뱃 (IOI13_wombats) C++17
12 / 100
156 ms 97448 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,l,r,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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 90972 KB Output is correct
2 Incorrect 12 ms 90968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4536 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 1 ms 8640 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8536 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 54 ms 10836 KB Output is correct
12 Correct 1 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 156 ms 10844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 97448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 156 ms 10848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 156 ms 10844 KB Output isn't correct
2 Halted 0 ms 0 KB -