Submission #1067844

# Submission time Handle Problem Language Result Execution time Memory
1067844 2024-08-21T04:28:53 Z sleepntsheep Wombats (IOI13_wombats) C++17
55 / 100
20000 ms 24208 KB
#pragma GCC optimize("O3,unroll-loops")
#include "wombats.h"
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cassert>
using namespace std;

template <typename T>
using ve = vector<T>;

#ifndef ROW
#define ROW 5000
#endif

int r, c, h[ROW][100], v[ROW][100];
int ans_5[100][100];

void calc_sub5_dp() {
	static int dp[2][100];
	for (int ii = 0; ii < c; ++ii) {
		/* find answer for (V1, V2) where V1 = ii */
		memset(dp[0], 63, sizeof dp[0]);
		dp[0][ii] = 0;

		int I = 0;
		for (int i = 0; i < r; ++i, I ^= 1) {
			static int pre[100], suf[100], ph[100]; /* annoying ahh math */ 
			ph[0] = 0;
			for (int j = 0; j + 1 < c; ++j)
				ph[j + 1] = ph[j] + h[i][j];

			pre[0] = dp[I][0]; /* - ph[0] = 0; */
			for (int j = 1; j < c; ++j) pre[j] = min(pre[j - 1], dp[I][j] - ph[j]);
			suf[c - 1] = dp[I][c - 1] + ph[c - 1];
			for (int j = c - 2; j >= 0; --j) suf[j] = min(suf[j + 1], dp[I][j] + ph[j]);

			for (int j = 0; j < c; ++j) {
				dp[I][j] = min({dp[I][j], ph[j] + pre[j], suf[j] - ph[j]});
				if (i + 1 < r)
					dp[!I][j] = dp[I][j] + v[i][j];
			}
		}
		for (int jj = 0; jj < c; ++jj) ans_5[ii][jj] = dp[(r - 1) & 1][jj];
	}
}

void changeH(int P, int Q, int W) {
	h[P][Q] = W;
	calc_sub5_dp();
}

void changeV(int P, int Q, int W) {
	v[P][Q] = W;
	calc_sub5_dp();
}


void init(int R, int C, int H[ROW][200], int V[ROW][200]) {
	r = R, c = C;

	for (int i = 0; i + 1 < r; ++i) for (int j = 0; j < c; ++j)
		v[i][j] = V[i][j];
	for (int i = 0 ; i < r; ++i) for (int j = 0; j + 1 < c; ++j)
		h[i][j] = H[i][j];

	calc_sub5_dp();
}

int escape(int V1, int V2) {
	return ans_5[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 12 ms 9560 KB Output is correct
2 Correct 12 ms 9564 KB Output is correct
3 Correct 46 ms 11224 KB Output is correct
4 Correct 12 ms 9564 KB Output is correct
5 Correct 11 ms 9780 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 36 ms 7516 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 348 ms 6636 KB Output is correct
2 Correct 373 ms 6640 KB Output is correct
3 Correct 343 ms 6640 KB Output is correct
4 Correct 345 ms 6492 KB Output is correct
5 Correct 348 ms 6492 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1708 ms 6636 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 12124 KB Output is correct
2 Correct 56 ms 12124 KB Output is correct
3 Correct 56 ms 12124 KB Output is correct
4 Correct 75 ms 12880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 350 ms 6892 KB Output is correct
2 Correct 332 ms 6492 KB Output is correct
3 Correct 342 ms 6652 KB Output is correct
4 Correct 359 ms 6488 KB Output is correct
5 Correct 339 ms 6740 KB Output is correct
6 Correct 65 ms 12120 KB Output is correct
7 Correct 61 ms 12120 KB Output is correct
8 Correct 57 ms 12120 KB Output is correct
9 Correct 76 ms 12884 KB Output is correct
10 Correct 11 ms 9560 KB Output is correct
11 Correct 18 ms 9784 KB Output is correct
12 Correct 45 ms 11348 KB Output is correct
13 Correct 12 ms 9564 KB Output is correct
14 Correct 15 ms 9784 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 38 ms 7552 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1729 ms 6492 KB Output is correct
28 Execution timed out 20050 ms 12116 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 340 ms 6632 KB Output is correct
2 Correct 331 ms 6488 KB Output is correct
3 Correct 342 ms 6492 KB Output is correct
4 Correct 351 ms 6636 KB Output is correct
5 Correct 335 ms 6492 KB Output is correct
6 Correct 57 ms 12124 KB Output is correct
7 Correct 57 ms 12124 KB Output is correct
8 Correct 61 ms 12120 KB Output is correct
9 Correct 76 ms 12952 KB Output is correct
10 Correct 12 ms 9564 KB Output is correct
11 Correct 12 ms 9564 KB Output is correct
12 Correct 46 ms 11348 KB Output is correct
13 Correct 12 ms 9564 KB Output is correct
14 Correct 12 ms 9784 KB Output is correct
15 Runtime error 3313 ms 24208 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -