답안 #1067838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067838 2024-08-21T04:17:00 Z sleepntsheep 웜뱃 (IOI13_wombats) C++17
9 / 100
228 ms 24248 KB
#include "wombats.h"
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

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


int r, c, h[5000][100], v[5000][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) {
			if (i >= 1)
				for (int j = 0; j < c; ++j)
					dp[I][j] = dp[!I][j] + v[i - 1][j];

			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[i] = min(pre[i - 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[i] = min(suf[i + 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]});
		}
		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[5000][200], int V[5000][200]) {
	r = R, c = C;
	if (c > 100) return;

	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];
	return 0;
}

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 14 ms 6232 KB Output is correct
2 Correct 15 ms 6232 KB Output is correct
3 Correct 51 ms 9040 KB Output is correct
4 Correct 15 ms 6236 KB Output is correct
5 Correct 15 ms 6232 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 424 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 210 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 24248 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 228 ms 780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 210 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -