样例会输出9而不是7
by natie @ 2024-08-19 13:14:33
```cpp
if(find(a[i].d1)==find(a[i-1].d1))
{
continue;
}
``````
改
```cpp
if(find(a[i].d1)==find(a[i].d2))
{
continue;
}
``````
即可过。
by xujinxuan01 @ 2024-08-19 13:22:17
谢谢!
by natie @ 2024-08-19 13:22:49
```cpp
if(find(a[i].d1)==find(a[i-1].d1))
{
continue;
}
``````
这里`i-1`是上一条边,而应该判的是该边的两端是否在同一个连通块内,因为最小生成树不能有环。
by xujinxuan01 @ 2024-08-19 13:23:50
~~其实是大改的时候忘记改了~~
by natie @ 2024-08-19 13:30:05