Submission #763406

# Submission time Handle Problem Language Result Execution time Memory
763406 2023-06-22T09:22:25 Z SanguineChameleon Wombats (IOI13_wombats) C++17
55 / 100
20000 ms 26160 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
 
const int maxN = 5e3 + 20;
const int maxM = 2e2 + 20;
int hor[5020][220];
int ver[5020][220];
int memo[220][220];
int tmp[5020][220];
int dp[5020][220];
int N, M;
 

void calc(int id, int lt, int rt) {
	for (int X = 0; X < M; X++) {
		dp[lt][X] = 0;
		for (int i = X - 1; i >= 0; i--) {
			dp[lt][i] = dp[lt][i + 1] + hor[lt][i];
		}
		for (int i = X + 1; i < M; i++) {
			dp[lt][i] = dp[lt][i - 1] + hor[lt][i - 1];
		}
		for (int i = lt + 1; i <= rt; i++) {
			for (int j = 0; j < M; j++) {
				tmp[i][j] = dp[i - 1][j] + ver[i - 1][j];
				dp[i][j] = tmp[i][j];
			}
			int best = tmp[i][0];
			for (int j = 1; j < M; j++) {
				best = min(best + hor[i][j - 1], tmp[i][j]);
				dp[i][j] = min(dp[i][j], best);
			}
			best = tmp[i][M - 1];
			for (int j = M - 2; j >= 0; j--) {
				best = min(best + hor[i][j], tmp[i][j]);
				dp[i][j] = min(dp[i][j], best);
			}
		}
		for (int Y = 0; Y < M; Y++) {
			memo[X][Y] = dp[rt][Y];
		}
	}
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
	N = R;
	M = C;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M - 1; j++) {
			hor[i][j] = H[i][j];
		}
	}
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < M; j++) {
			ver[i][j] = V[i][j];
		}
	}
	calc(1, 0, N - 1);
}

void changeH(int P, int Q, int W) {
	hor[P][Q] = W;
	calc(1, 0, N - 1);
}
 
void changeV(int P, int Q, int W) {
	ver[P][Q] = W;
	calc(1, 0, N - 1);
}
 
 
int escape(int V1, int V2) {
	return memo[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;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 17108 KB Output is correct
2 Correct 27 ms 17044 KB Output is correct
3 Correct 80 ms 18688 KB Output is correct
4 Correct 27 ms 17108 KB Output is correct
5 Correct 25 ms 17108 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 388 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 54 ms 1440 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 375 ms 932 KB Output is correct
2 Correct 371 ms 928 KB Output is correct
3 Correct 372 ms 920 KB Output is correct
4 Correct 374 ms 852 KB Output is correct
5 Correct 370 ms 912 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1868 ms 920 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 25352 KB Output is correct
2 Correct 60 ms 25348 KB Output is correct
3 Correct 76 ms 25352 KB Output is correct
4 Correct 104 ms 26072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 372 ms 1036 KB Output is correct
2 Correct 364 ms 920 KB Output is correct
3 Correct 375 ms 912 KB Output is correct
4 Correct 373 ms 852 KB Output is correct
5 Correct 368 ms 912 KB Output is correct
6 Correct 71 ms 25428 KB Output is correct
7 Correct 74 ms 25356 KB Output is correct
8 Correct 75 ms 25300 KB Output is correct
9 Correct 103 ms 26160 KB Output is correct
10 Correct 26 ms 17108 KB Output is correct
11 Correct 26 ms 17160 KB Output is correct
12 Correct 93 ms 18812 KB Output is correct
13 Correct 26 ms 17108 KB Output is correct
14 Correct 25 ms 17164 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 54 ms 1400 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1848 ms 912 KB Output is correct
28 Execution timed out 20089 ms 25700 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 372 ms 908 KB Output is correct
2 Correct 365 ms 924 KB Output is correct
3 Correct 382 ms 928 KB Output is correct
4 Correct 374 ms 920 KB Output is correct
5 Correct 369 ms 852 KB Output is correct
6 Correct 68 ms 25292 KB Output is correct
7 Correct 63 ms 25300 KB Output is correct
8 Correct 68 ms 25356 KB Output is correct
9 Correct 99 ms 26072 KB Output is correct
10 Correct 26 ms 17108 KB Output is correct
11 Correct 22 ms 17032 KB Output is correct
12 Correct 78 ms 18620 KB Output is correct
13 Correct 26 ms 17160 KB Output is correct
14 Correct 26 ms 17108 KB Output is correct
15 Correct 3817 ms 25520 KB Output is correct
16 Execution timed out 20017 ms 25688 KB Time limit exceeded
17 Halted 0 ms 0 KB -