求助 LCT 写法
  • 板块学术版
  • 楼主cowardTester
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/12/2 10:24
  • 上次更新2024/12/2 17:44:38
查看原帖
求助 LCT 写法
711690
cowardTester楼主2024/12/2 10:24

Rt, 在实现 LCT 模板题中 cut 函数时,我两种写法得到的结果不同(第二种 93pts WA test 8),想问一下原因,谢谢!

两种写法中 cut 函数:

void cut(int x,int y){
    makeroot(x);
    if(findroot(y)==x&&t[y].fa==x&&t[y].ls==0)t[x].rs=t[y].fa=0,psu(x);
}
void cut(int x,int y){
    makeroot(x);
    if(t[y].fa==x&&findroot(y)==x&&t[y].ls==0)t[x].rs=t[y].fa=0,psu(x);
}

即交换 && 前后条件顺序。

2024/12/2 10:24
加载中...