답안 #249936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249936 2020-07-16T13:59:18 Z MarcoMeijer 웜뱃 (IOI13_wombats) C++14
55 / 100
20000 ms 173048 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()

const int MX = 6000;
int r, c;
int h[MX][200], v[MX][200];

int SEG[200][200][1000];
int dp[200][200][2];
int n;

void createSeg(int x, int p) {
    int bg=x*20;
    int ed=min(x*20+20, r);

    int m = ed-bg;
    RE(i,c) RE(j,c) {
        int ans = 0;
        REP(k,i,j) ans += h[bg][k];
        REV(k,j,i) ans += h[bg][k];
        dp[i][j][0] = ans;
    }

    REP(y,1,m) {
        bool cur=y%2;
        RE(i,c) RE(j,c) dp[i][j][cur] = dp[i][j][!cur]+v[bg+y-1][j];;
        RE(i,c) {
            REP(j,1,c  ) dp[i][j][cur] = min(dp[i][j][cur], dp[i][j-1][cur]+h[bg+y][j-1]);
            REV(j,0,c-1) dp[i][j][cur] = min(dp[i][j][cur], dp[i][j+1][cur]+h[bg+y][j]);
        }
    }
    bool cur=!(m%2);
    RE(i,c) RE(j,c) SEG[i][j][p] = dp[i][j][cur];
}
void combineSeg(int x, int p) {
    x = (x+1)*20-1;
    RE(i,c) {
        RE(j,c) {
            SEG[i][j][p] = INF;
            RE(k,c)
                SEG[i][j][p] = min(SEG[i][j][p], SEG[i][k][p*2+1]+SEG[k][j][p*2+2]+v[x][k]);
        }
    }
}
void buildSeg(int p=0, int l=0, int r=n-1) {
    if(l == r) {
        createSeg(l, p);
        return;
    }
    int m=(l+r)/2;
    buildSeg(p*2+1,l,m);
    buildSeg(p*2+2,m+1,r);
    combineSeg(m,p);
}
void updateSeg(int i, int p=0, int l=0, int r=n-1) {
    if(i < l || i > r) return;
    if(l == r) {
        createSeg(i,p);
        return;
    }
    int m=(l+r)/2;
    updateSeg(i,p*2+1,l,m);
    updateSeg(i,p*2+2,m+1,r);
    combineSeg(m,p);
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    r=R, c=C;
    RE(i,r) RE(j,c) h[i][j]=H[i][j]; 
    RE(i,r) RE(j,c) v[i][j]=V[i][j];
    n = (r+19)/20;
    buildSeg();
}

void changeH(int P, int Q, int W) {
    h[P][Q] = W;
    updateSeg(P/20);
}

void changeV(int P, int Q, int W) {
    v[P][Q] = W;
    updateSeg(P/20);
}

int escape(int V1, int V2) {
    return SEG[V1][V2][0];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12160 KB Output is correct
2 Correct 7 ms 12032 KB Output is correct
3 Correct 86 ms 13944 KB Output is correct
4 Correct 8 ms 12160 KB Output is correct
5 Correct 8 ms 12160 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 2048 KB Output is correct
5 Correct 1 ms 2048 KB Output is correct
6 Correct 1 ms 2048 KB Output is correct
7 Correct 2 ms 2048 KB Output is correct
8 Correct 1 ms 1920 KB Output is correct
9 Correct 2 ms 2048 KB Output is correct
10 Correct 1 ms 1920 KB Output is correct
11 Correct 86 ms 3064 KB Output is correct
12 Correct 2 ms 2048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2480 ms 40208 KB Output is correct
2 Correct 3566 ms 39492 KB Output is correct
3 Correct 3127 ms 40184 KB Output is correct
4 Correct 2929 ms 40188 KB Output is correct
5 Correct 3599 ms 39416 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 18298 ms 40168 KB Output is correct
10 Correct 0 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 16000 KB Output is correct
2 Correct 11 ms 16000 KB Output is correct
3 Correct 11 ms 16128 KB Output is correct
4 Correct 52 ms 17016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2493 ms 40204 KB Output is correct
2 Correct 3598 ms 39296 KB Output is correct
3 Correct 3188 ms 40168 KB Output is correct
4 Correct 2986 ms 40184 KB Output is correct
5 Correct 3698 ms 39288 KB Output is correct
6 Correct 11 ms 16128 KB Output is correct
7 Correct 10 ms 16000 KB Output is correct
8 Correct 11 ms 16160 KB Output is correct
9 Correct 52 ms 17104 KB Output is correct
10 Correct 8 ms 12160 KB Output is correct
11 Correct 7 ms 12160 KB Output is correct
12 Correct 89 ms 13944 KB Output is correct
13 Correct 11 ms 12160 KB Output is correct
14 Correct 8 ms 12160 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 2 ms 2048 KB Output is correct
19 Correct 1 ms 2048 KB Output is correct
20 Correct 2 ms 2048 KB Output is correct
21 Correct 2 ms 2048 KB Output is correct
22 Correct 1 ms 1920 KB Output is correct
23 Correct 1 ms 2048 KB Output is correct
24 Correct 1 ms 1920 KB Output is correct
25 Correct 97 ms 3320 KB Output is correct
26 Correct 2 ms 2048 KB Output is correct
27 Correct 18242 ms 40168 KB Output is correct
28 Execution timed out 20020 ms 56296 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2527 ms 40184 KB Output is correct
2 Correct 3625 ms 39416 KB Output is correct
3 Correct 3202 ms 40172 KB Output is correct
4 Correct 3004 ms 40172 KB Output is correct
5 Correct 3678 ms 39296 KB Output is correct
6 Correct 11 ms 16128 KB Output is correct
7 Correct 11 ms 16000 KB Output is correct
8 Correct 15 ms 16128 KB Output is correct
9 Correct 52 ms 17088 KB Output is correct
10 Correct 8 ms 12160 KB Output is correct
11 Correct 10 ms 12160 KB Output is correct
12 Correct 89 ms 13944 KB Output is correct
13 Correct 8 ms 12160 KB Output is correct
14 Correct 8 ms 12160 KB Output is correct
15 Execution timed out 20057 ms 173048 KB Time limit exceeded
16 Halted 0 ms 0 KB -