QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#540632#8932. Bingoucup-team052#WA 1ms7684kbC++231.9kb2024-08-31 17:33:482024-08-31 17:33:48

Judging History

你现在查看的是最新测评结果

  • [2024-08-31 17:33:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7684kb
  • [2024-08-31 17:33:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int INF = 0x3f3f3f3f;
const int N = 10005;

struct edge {
	int v, l, k;
	edge (int a = 0, int b = 0, int c = 0) : v(a), l(b), k(c) {}
};

vector <edge> adj[N];
int fa[N], l[N], k[N], c[N];
int n, m;

ll f[N][N], tf[N]; // f[u][i] : cost
int g[N][N], tg[N]; // g[u][i] : u eat i turtles, minimum count of turtle
void dfs1(int u) {
	memset(f[u], 0x3f, sizeof(f[u]));
	memset(g[u], 0x3f, sizeof(g[u]));
	for (int i = 0; i <= m; i++) g[u][i] = f[u][i] = 0;
	/*
	for (int i = 0; i <= m; i++) {
		g[u][i] = max(0, c[u] - i);
		if (i + g[u][i] > k[u]) {
			g[u][i] = -1;
			continue;
		}
		f[u][i] = 1ll * (i + g[u][i]) * l[u];
	}
	*/
	for (auto t : adj[u]) {
		int v = t.v;
		if (v == fa[u]) continue;
		fa[v] = u; l[v] = t.l; k[v] = t.k; dfs1(v);
		memset(tg, 0x3f, sizeof(tg));
		memset(tf, 0x3f, sizeof(tf));
		for (int i = 0; i <= n; i++) {
			if (g[u][i] == INF) continue;
			for (int j = 0; j <= n - i; j++) {
				if (g[v][j] == INF) continue;
				int ng = max(g[u][i], g[v][j]);
				if (ng < tg[i + j]) {
					tf[i + j] = f[u][i] + f[v][j];
					tg[i + j] = ng;
				} else if (ng == tg[i + j]) {
					tf[i + j] = min(tf[i + j], f[u][i] + f[v][j]);
				}
			}
		}
		memcpy(f[u], tf, sizeof(f[u]));
		memcpy(f[u], tg, sizeof(g[u]));
	}
	for (int i = 0; i <= m; i++) {
		if (g[u][i] == INF) continue;
		g[u][i] = max(g[u][i], c[u] - i);
	}
	for (int i = 0; i < m; i++) {
		if (max(0, g[u][i] - 1) < g[u][i + 1]) {
			
		}
	}
	for (int i = 0; i <= m; i++) {
		if (i + g[u][i] * 2 > k[u]) {
			g[u][i] = INF;
		}
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i < n; i++) {
		int u, v, l, k;
		cin >> u >> v >> l >> k;
		adj[u].emplace_back(v, l, k);
		adj[v].emplace_back(u, l, k);
	}
	k[1] = 1e9;
	for (int i = 2; i <= n; i++) cin >> c[i];
	dfs1(1);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7684kb

input:

6
7 3
12 3
9 10
249 51
1369 37
2 1

output:


result:

wrong answer 1st lines differ - expected: '9', found: ''