# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
383550 | alireza_kaviani | Wombats (IOI13_wombats) | C++11 | 4552 ms | 29804 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
const int MAXN = 5010;
const int MAXC = 300;
const int MOD = 1e9 + 7;
int n , m , h[MAXN][MAXC] , v[MAXN][MAXC] , dp[MAXC][MAXC];
void solve(){
if(n * m * m >= int(2e6)) return;
for(int i = 0 ; i < m ; i++){
fill(dp[i] , dp[i] + MAXC , MOD);
dp[i][i] = 0;
for(int j = 0 ; j < n ; j++){
if(j) for(int k = 0 ; k < m ; k++) dp[i][k] += v[j - 1][k];
for(int k = 1 ; k < m ; k++){
dp[i][k] = min(dp[i][k] , dp[i][k - 1] + h[j][k - 1]);
}
for(int k = m - 2 ; k >= 0 ; k--){
dp[i][k] = min(dp[i][k] , dp[i][k + 1] + h[j][k]);
}
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
/* ... */
int sum = 0;
n = R; m = C;
for(int i = 0 ; i < 5000 ; i++){
for(int j = 0 ; j < 200 ; j++){
h[i][j] = H[i][j];
v[i][j] = V[i][j];
}
}
solve();
}
void changeH(int P, int Q, int W) {
h[P][Q] = W;
solve();
}
void changeV(int P, int Q, int W) {
v[P][Q] = W;
solve();
}
int escape(int V1, int V2) {
return dp[V1][V2];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |