답안 #1028822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028822 2024-07-20T09:12:21 Z tolbi 웜뱃 (IOI13_wombats) C++17
0 / 100
574 ms 20316 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXR = 100;
const int MAXC = 100;
int dp[MAXR*4][MAXC][MAXC]={};
int H[MAXR][MAXC],V[MAXR][MAXC];
int C,sz;
bool non[MAXR*4];
void merge(int x){
    if (non[x]) return;
    if (non[x*2+2]){
        for (int i = 0; i < C; i++){
            for (int j = 0; j < C; j++){
                dp[x][i][j]=dp[x*2+1][i][j];
            }
        }
        return;
    }
    for (int i = 0; i < C; i++){
        for (int j = 0; j < C; j++){
            dp[x][i][j]=dp[x*2+1][i][0]+dp[x*2+2][0][j];
            for (int k = 0; k < C; k++){
                dp[x][i][j]=min(dp[x][i][j],dp[x*2+1][i][k]+dp[x*2+2][k][j]);
            }
        }
    }
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    ::C=C;
    sz=((1LL<<((int)(ceil(log2(R)+1))))-1);
    for (int i = 0; i < R; i++){
        for (int j = 0; j < C; j++){
            if (i+1<R) ::H[i][j]=H[i][j];
            else ::H[i][j]=0;
            if (j+1<C) ::V[i][j]=V[i][j];
            else ::H[i][j]=0;
        }
    }
    for (int x = 0; x < R; x++){
        for (int i = 0; i < C; i++){
            int somma = 0;
            for (int j = i; j < C; j++){
                dp[sz/2+x][i][j]=somma+V[x][j];
                somma+=H[x][j];
            }
            somma = 0;
            for (int j = i-1; j >= 0; j--){
                somma+=H[x][j];
                dp[sz/2+x][i][j]=somma+V[x][j];
            }
        }
    }
    for (int i = R+sz/2; i < sz; i++){
        non[i]=true;
    }
    for (int i = ((1LL<<((int)(ceil(log2(R)+1))))-1)/2-1; i >= 0; i--){
        merge(i);
    }
}

void changeH(int P, int Q, int W) {
    H[P][Q]=W;
    for (int i = 0; i < C; i++){
        int somma = 0;
        for (int j = i; j < C; j++){
            dp[P+sz/2][i][j]=somma+V[P][j];
            somma+=H[P][j];
        }
        somma = 0;
        for (int j = i-1; j >= 0; j--){
            somma+=H[P][j];
            dp[P+sz/2][i][j]=somma+V[P][j];
        }
    }
    P+=sz/2;
    while (P){
        P=(P-1)/2;
        merge(P);
    }
}

void changeV(int P, int Q, int W) {
    V[P][Q]=W;
    for (int i = 0; i < C; i++){
        int somma = 0;
        for (int j = i; j < C; j++){
            dp[P+sz/2][i][j]=somma+V[P][j];
            somma+=H[P][j];
        }
        somma = 0;
        for (int j = i-1; j >= 0; j--){
            somma+=H[P][j];
            dp[P+sz/2][i][j]=somma+V[P][j];
        }
    }
    P+=sz/2;
    while (P){
        P=(P-1)/2;
        merge(P);
    }
}

int escape(int V1, int V2) {
    return dp[0][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 Runtime error 6 ms 12380 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 860 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 571 ms 9596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 20316 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 574 ms 9556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 541 ms 9556 KB Output isn't correct
2 Halted 0 ms 0 KB -