답안 #104922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104922 2019-04-09T18:22:50 Z eriksuenderhauf 웜뱃 (IOI13_wombats) C++11
55 / 100
20000 ms 263168 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "wombats.h"
//#include "grader.h"
using namespace std;
typedef long long int ll;
const int INF = 1e9 + 7;
const int MAXN = 20005;
const double eps = 1e-9;
int RW, C, root = 0, segSz = 1;
int h[5000][200], v[5000][200], L[MAXN], R[MAXN];
int dp[MAXN][100][100];

void merge(int cur) {
	for (int i = 0; i < C; i++)
		for (int j = 0; j < C; j++)
			dp[cur][i][j] = INF;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				dp[cur][i][j] = min(dp[cur][i][j], dp[L[cur]][i][k] + dp[R[cur]][k][j]);
			}
		}
	}
}

void init(int cur, int l, int r) {
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++)
			dp[cur][i][j] = INF;
		dp[cur][i][i] = 0;
	}
	for (int i = 0; i < C; i++) {
		for (int j = i + 1; j < C; j++)
			dp[cur][i][j] = min(dp[cur][i][j], dp[cur][i][j - 1] + h[l][j - 1]);
		for (int j = i - 1; j > -1; j--)
			dp[cur][i][j] = min(dp[cur][i][j], dp[cur][i][j + 1] + h[l][j]);
	}
	for (int i = 0; i < C; i++)
		for (int j = 0; j < C; j++)
			dp[cur][i][j] += v[l][j];
}

void upd(int l, int r, int cur, int ind) {
	if (r < ind || ind < l) return;
	if (ind <= l && r <= ind) {
		init(cur, l, r);
		return;
	}
	int m = (l + r) / 2;
	upd(l, m, L[cur], ind);
	upd(m + 1, r, R[cur], ind);
	merge(cur);
}

void build(int l, int r, int &cur) {
	cur = segSz++;
	if (l == r) {
		init(cur, l, r);
		return;
	}
	int m = (l + r) / 2;
	build(l, m, L[cur]);
	build(m + 1, r, R[cur]);
	merge(cur);
}

void init(int R1, int C1, int H[5000][200], int V[5000][200]) {
	RW = R1, C = C1;
	for (int i = 0; i < RW; i++)
		for (int j = 0; j + 1 < C; j++)
			h[i][j] = H[i][j];
	for (int i = 0; i + 1 < RW; i++)
		for (int j = 0; j < C; j++)
			v[i][j] = V[i][j];
	build(0, RW - 1, root);
}

void changeH(int p, int q, int w) {
	h[p][q] = w;
	upd(0, RW - 1, root, p);
}

void changeV(int p, int q, int w) {
	v[p][q] = w;
	upd(0, RW - 1, root, p);
}

int escape(int a, int b) {
	return dp[root][a][b];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 49016 KB Output is correct
2 Correct 40 ms 49016 KB Output is correct
3 Correct 109 ms 51832 KB Output is correct
4 Correct 42 ms 49016 KB Output is correct
5 Correct 41 ms 49020 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 4 ms 896 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 75 ms 1936 KB Output is correct
12 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1059 ms 8444 KB Output is correct
2 Correct 858 ms 8436 KB Output is correct
3 Correct 853 ms 8568 KB Output is correct
4 Correct 858 ms 8668 KB Output is correct
5 Correct 865 ms 8568 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3961 ms 8520 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 60528 KB Output is correct
2 Correct 52 ms 60672 KB Output is correct
3 Correct 57 ms 60664 KB Output is correct
4 Correct 126 ms 61940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 835 ms 8500 KB Output is correct
2 Correct 878 ms 8312 KB Output is correct
3 Correct 886 ms 8512 KB Output is correct
4 Correct 822 ms 8532 KB Output is correct
5 Correct 810 ms 8312 KB Output is correct
6 Correct 48 ms 60536 KB Output is correct
7 Correct 46 ms 60664 KB Output is correct
8 Correct 48 ms 60764 KB Output is correct
9 Correct 113 ms 62144 KB Output is correct
10 Correct 38 ms 49016 KB Output is correct
11 Correct 36 ms 49016 KB Output is correct
12 Correct 94 ms 51704 KB Output is correct
13 Correct 36 ms 49016 KB Output is correct
14 Correct 36 ms 49016 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 4 ms 896 KB Output is correct
19 Correct 3 ms 896 KB Output is correct
20 Correct 3 ms 896 KB Output is correct
21 Correct 4 ms 896 KB Output is correct
22 Correct 3 ms 896 KB Output is correct
23 Correct 3 ms 896 KB Output is correct
24 Correct 3 ms 896 KB Output is correct
25 Correct 84 ms 3376 KB Output is correct
26 Correct 3 ms 868 KB Output is correct
27 Correct 3784 ms 8596 KB Output is correct
28 Runtime error 3808 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 802 ms 8484 KB Output is correct
2 Correct 760 ms 8540 KB Output is correct
3 Correct 816 ms 8696 KB Output is correct
4 Correct 892 ms 8592 KB Output is correct
5 Correct 816 ms 8692 KB Output is correct
6 Correct 51 ms 60664 KB Output is correct
7 Correct 48 ms 60664 KB Output is correct
8 Correct 54 ms 60664 KB Output is correct
9 Correct 87 ms 61944 KB Output is correct
10 Correct 44 ms 49144 KB Output is correct
11 Correct 45 ms 49016 KB Output is correct
12 Correct 112 ms 51952 KB Output is correct
13 Correct 40 ms 49144 KB Output is correct
14 Correct 41 ms 49016 KB Output is correct
15 Execution timed out 20065 ms 207972 KB Time limit exceeded
16 Halted 0 ms 0 KB -