Submission #383552

# Submission time Handle Problem Language Result Execution time Memory
383552 2021-03-30T09:27:14 Z alireza_kaviani Wombats (IOI13_wombats) C++11
55 / 100
4500 ms 21100 KB
#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(5e7))	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

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
wombats.cpp: In function 'void init(int, int, int (*)[200], int (*)[200])':
wombats.cpp:30:6: warning: unused variable 'sum' [-Wunused-variable]
   30 |  int sum = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 25 ms 15980 KB Output is correct
2 Correct 31 ms 15980 KB Output is correct
3 Correct 103 ms 17772 KB Output is correct
4 Correct 25 ms 15980 KB Output is correct
5 Correct 27 ms 15980 KB Output is correct
6 Correct 10 ms 12140 KB Output is correct
7 Correct 9 ms 12140 KB Output is correct
8 Correct 9 ms 12140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 12140 KB Output is correct
2 Correct 11 ms 12140 KB Output is correct
3 Correct 9 ms 12140 KB Output is correct
4 Correct 10 ms 12140 KB Output is correct
5 Correct 10 ms 12140 KB Output is correct
6 Correct 10 ms 12140 KB Output is correct
7 Correct 10 ms 12140 KB Output is correct
8 Correct 10 ms 12140 KB Output is correct
9 Correct 11 ms 12140 KB Output is correct
10 Correct 10 ms 12140 KB Output is correct
11 Correct 91 ms 13164 KB Output is correct
12 Correct 10 ms 12140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 906 ms 12524 KB Output is correct
2 Correct 900 ms 12524 KB Output is correct
3 Correct 922 ms 12396 KB Output is correct
4 Correct 920 ms 12396 KB Output is correct
5 Correct 918 ms 12524 KB Output is correct
6 Correct 10 ms 12140 KB Output is correct
7 Correct 9 ms 12140 KB Output is correct
8 Correct 9 ms 12140 KB Output is correct
9 Correct 4495 ms 12424 KB Output is correct
10 Correct 11 ms 12140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 20080 KB Output is correct
2 Correct 89 ms 20076 KB Output is correct
3 Correct 108 ms 19948 KB Output is correct
4 Correct 131 ms 20716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 905 ms 12396 KB Output is correct
2 Correct 922 ms 12396 KB Output is correct
3 Correct 928 ms 12396 KB Output is correct
4 Correct 918 ms 12424 KB Output is correct
5 Correct 898 ms 12524 KB Output is correct
6 Correct 90 ms 19948 KB Output is correct
7 Correct 88 ms 19948 KB Output is correct
8 Correct 88 ms 19948 KB Output is correct
9 Correct 148 ms 20716 KB Output is correct
10 Correct 24 ms 15980 KB Output is correct
11 Correct 27 ms 15980 KB Output is correct
12 Correct 103 ms 17644 KB Output is correct
13 Correct 26 ms 15980 KB Output is correct
14 Correct 25 ms 15980 KB Output is correct
15 Correct 9 ms 12140 KB Output is correct
16 Correct 9 ms 12140 KB Output is correct
17 Correct 9 ms 12140 KB Output is correct
18 Correct 9 ms 12140 KB Output is correct
19 Correct 10 ms 12140 KB Output is correct
20 Correct 11 ms 12140 KB Output is correct
21 Correct 12 ms 12140 KB Output is correct
22 Correct 10 ms 12140 KB Output is correct
23 Correct 10 ms 12140 KB Output is correct
24 Correct 10 ms 12140 KB Output is correct
25 Correct 91 ms 13548 KB Output is correct
26 Correct 10 ms 12140 KB Output is correct
27 Correct 4500 ms 12500 KB Output is correct
28 Incorrect 131 ms 20332 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 908 ms 12396 KB Output is correct
2 Correct 895 ms 12524 KB Output is correct
3 Correct 922 ms 12628 KB Output is correct
4 Correct 907 ms 12396 KB Output is correct
5 Correct 901 ms 12524 KB Output is correct
6 Correct 93 ms 19948 KB Output is correct
7 Correct 88 ms 19948 KB Output is correct
8 Correct 88 ms 20076 KB Output is correct
9 Correct 162 ms 21100 KB Output is correct
10 Correct 25 ms 15980 KB Output is correct
11 Correct 25 ms 15980 KB Output is correct
12 Correct 104 ms 18028 KB Output is correct
13 Correct 25 ms 15980 KB Output is correct
14 Correct 25 ms 15980 KB Output is correct
15 Incorrect 233 ms 20020 KB Output isn't correct
16 Halted 0 ms 0 KB -