如果你TLE 10pts
查看原帖
如果你TLE 10pts
593907
Taoran_01楼主2024/4/25 17:23

如果你除了Test #5都TLE Like This,请检查你的add_edge()函数。
注意建反向边的时候价值要改为负的。

Incorrect Code:

void add_edge(int x, int y, int z, int cost) {
	e[tot]={y, head[x], z, cost}, head[x]=tot++;
	e[tot]={x, head[y], 0, cost}, head[y]=tot++;
}

Correct Code:

void add_edge(int x, int y, int z, int cost) {
	e[tot]={y, head[x], z, cost}, head[x]=tot++;
	e[tot]={x, head[y], 0, -cost}, head[y]=tot++;
}
2024/4/25 17:23
加载中...