답안 #1067843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067843 2024-08-21T04:27:26 Z sleepntsheep 웜뱃 (IOI13_wombats) C++17
55 / 100
20000 ms 33952 KB
#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][101];
	for (int ii = 0; ii < c; ++ii) {
		/* find answer for (V1, V2) where V1 = ii */
		memset(dp, 63, sizeof dp);
		dp[0][ii] = 0;

		int I = 0;
		for (int i = 0; i < r; ++i, I ^= 1) {
			static int pre[102], suf[102], ph[102]; /* 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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 9564 KB Output is correct
2 Correct 12 ms 9564 KB Output is correct
3 Correct 49 ms 12416 KB Output is correct
4 Correct 12 ms 9564 KB Output is correct
5 Correct 11 ms 9564 KB Output is correct
6 Correct 0 ms 2480 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 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 6600 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 6576 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 41 ms 8788 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 349 ms 6492 KB Output is correct
2 Correct 332 ms 6488 KB Output is correct
3 Correct 347 ms 6724 KB Output is correct
4 Correct 343 ms 7000 KB Output is correct
5 Correct 336 ms 6724 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2464 KB Output is correct
9 Correct 1685 ms 6716 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 12124 KB Output is correct
2 Correct 54 ms 12124 KB Output is correct
3 Correct 55 ms 12124 KB Output is correct
4 Correct 74 ms 13392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 6492 KB Output is correct
2 Correct 335 ms 6712 KB Output is correct
3 Correct 355 ms 6488 KB Output is correct
4 Correct 351 ms 6488 KB Output is correct
5 Correct 342 ms 6488 KB Output is correct
6 Correct 55 ms 12252 KB Output is correct
7 Correct 56 ms 12120 KB Output is correct
8 Correct 55 ms 12124 KB Output is correct
9 Correct 90 ms 13396 KB Output is correct
10 Correct 13 ms 9800 KB Output is correct
11 Correct 12 ms 9560 KB Output is correct
12 Correct 48 ms 12392 KB Output is correct
13 Correct 11 ms 9564 KB Output is correct
14 Correct 17 ms 9788 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 41 ms 8888 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1720 ms 6716 KB Output is correct
28 Execution timed out 20025 ms 15776 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 342 ms 6488 KB Output is correct
2 Correct 339 ms 6488 KB Output is correct
3 Correct 342 ms 6492 KB Output is correct
4 Correct 394 ms 6492 KB Output is correct
5 Correct 339 ms 6488 KB Output is correct
6 Correct 55 ms 12124 KB Output is correct
7 Correct 59 ms 12120 KB Output is correct
8 Correct 55 ms 12124 KB Output is correct
9 Correct 94 ms 13524 KB Output is correct
10 Correct 12 ms 9792 KB Output is correct
11 Correct 12 ms 9804 KB Output is correct
12 Correct 46 ms 12408 KB Output is correct
13 Correct 12 ms 9564 KB Output is correct
14 Correct 14 ms 9812 KB Output is correct
15 Runtime error 3212 ms 33952 KB Execution killed with signal 6
16 Halted 0 ms 0 KB -