不能用ios::sync_with_stdio(0);然后用cin 会WA+TLE 不能把f[e[i].v]=f[x]-s[e[i].v]*e[i].w+(sum-s[e[i].v])e[i].w; 缩成f[e[i].v]=f[x]+(sum-2s[e[i].v])*e[i].w; 会WA