제출 #1263459

#제출 시각아이디문제언어결과실행 시간메모리
1263459kl0989e웜뱃 (IOI13_wombats)C++20
55 / 100
20088 ms17264 KiB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()

vector<vi> v(5000,vi(200,0)),h(5000,vi(200,0));
int n,m;

void init(int r, int c, int hh[5000][200], int vv[5000][200]) {
    n=r;
    m=c;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m-1; j++) {
            h[i][j]=hh[i][j];
        }
    }
    for (int i=0; i<n-1; i++) {
        for (int j=0; j<m; j++) {
            v[i][j]=vv[i][j];
        }
    }
}

void changeH(int p, int q, int w) {
    h[p][q]=w;
}

void changeV(int p, int q, int w) {
    v[p][q]=w;
}

int escape(int v1, int v2) {
    vi dp(m,1e9);
    dp[v1]=0;
    for (int j=0; j<m-1; j++) {
        dp[j+1]=min(dp[j+1],dp[j]+h[0][j]);
    }
    for (int j=m-2; j>=0; j--) {
        dp[j]=min(dp[j],dp[j+1]+h[0][j]);
    }
    for (int i=0; i<n-1; i++) {
        for (int j=0; j<m; j++) {
            dp[j]+=v[i][j];
        }
        for (int j=0; j<m-1; j++) {
            dp[j+1]=min(dp[j+1],dp[j]+h[i+1][j]);
        }
        for (int j=m-2; j>=0; j--) {
            dp[j]=min(dp[j],dp[j+1]+h[i+1][j]);
        }
    }
    return dp[v2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...