int check(long long x)
{
int i, j, cot = 0;
ans = 0, tot = 0;
For(i, 1, n) fa[i] = i;
for (i = 1, j = 1; i <= cnt1 && j <= cnt2;)
{
if (e2[j].w + x <= e1[i].w)
{
int fx = find(e2[j].u), fy = find(e2[j].v);
if (fx != fy)
fa[fx] = fy, ans += e2[j].w, cot++, step[++tot] = e2[j].id;
j++;
}
else
{
int fx = find(e1[i].u), fy = find(e1[i].v);
if (fx != fy)
fa[fx] = fy, ans += e1[i].w, step[++tot] = e1[i].id;
i++;
}
}
while (j <= cnt2)
{
int fx = find(e2[j].u), fy = find(e2[j].v);
if (fx != fy)
fa[fx] = fy, ans += e2[j].w, cot++, step[++tot] = e2[j].id;
j++;
}
while (i <= cnt1)
{
int fx = find(e1[i].u), fy = find(e1[i].v);
if (fx != fy)
fa[fx] = fy, ans += e1[i].w, step[++tot] = e1[i].id;
i++;
}
return cot;
}
check 函数这么写会不会有问题
e2 连向1的边
e1 其余的边