Submission #586547

# Submission time Handle Problem Language Result Execution time Memory
586547 2022-06-30T11:35:59 Z FatihSolak Wombats (IOI13_wombats) C++17
39 / 100
97 ms 11528 KB
#include "wombats.h"
#include <bits/stdc++.h>
#define R 5000
#define C 20
using namespace std;
int dp[C][R][C];
int r,c;
int h[R][C];
int v[R][C];
int preh[R][C];
void build(){
    for(int i = 0;i<r;i++){
        for(int j = 0;j<c;j++){
            preh[i][j] = h[i][j] + (j == 0?0:preh[i][j-1]);
        }
    }
    for(int x = 0;x<c;x++){
        for(int i = 0;i<r;i++){
            for(int j = 0;j<c;j++){
                dp[x][i][j] = 1e9;
            }
        }
        for(int i = 0;i<c;i++){
            dp[x][0][i] = abs((x == 0?0:preh[0][x-1]) -  (i == 0?0:preh[0][i-1]));
        }
        for(int i = 0;i<r-1;i++){
            for(int j = 0;j<c;j++){
                // if(x == 2){
                //     cout << i << " " << j << " " << dp[x][i][j] << endl;
                // }
                for(int d = 0;d<c;d++){
                    int cost = v[i][j];
                    cost += abs((j == 0?0:preh[i+1][j-1]) -  (d == 0?0:preh[i+1][d-1]));
                    dp[x][i+1][d] = min(dp[x][i+1][d], dp[x][i][j] + cost);
                }
            }
        }
    }
}
void init(int r_, int c_, int h_[5000][200], int v_[5000][200]) {
    r = r_;
    c = c_;
    for(int i = 0;i<r;i++){
        for(int j = 0;j<c;j++){
            h[i][j] = h_[i][j];
            v[i][j] = v_[i][j];
        }
    }
    build();
}

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

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

int escape(int v1, int v2) {
    return dp[v1][r-1][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 25 ms 5716 KB Output is correct
2 Correct 21 ms 5836 KB Output is correct
3 Correct 91 ms 8488 KB Output is correct
4 Correct 23 ms 5832 KB Output is correct
5 Correct 22 ms 5716 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 440 KB Output is correct
6 Correct 1 ms 444 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 440 KB Output is correct
11 Correct 70 ms 2768 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 1328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 10068 KB Output is correct
2 Correct 71 ms 10132 KB Output is correct
3 Correct 85 ms 10144 KB Output is correct
4 Correct 97 ms 11528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 1388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 1360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -