版本比较
严格次小生成树
正文
增加 5 行删除 5 行
28 行未改动29303132333334353637328 行未改动全部展开3663673683693703703713723733743 行未改动3783793803813823823833843853866 行未改动39339439539639739739839940040113 行未改动41541641741841941942042142242315 行未改动28 行未改动2 4 33 5 43 4 34 5 6
ans:11```
328 行未改动全部展开 while(top[x] != top[y]) { if(dep[top[x]] < dep[top[y]]) swap(x, y); node p = qry(1, dfn[top[x]], dfn[x]);
if(Val.fir == -INF) Val = p; else { if(Val.fir == p.fir) Val.sec = max(Val.sec, p.sec);3 行未改动 x = fa[top[x]]; } if(dep[x] > dep[y]) swap(x, y); node p = qry(1, dfn[x] + 1, dfn[y]);
if(Val.fir == -INF) Val = p; else { if(Val.fir == p.fir) Val.sec = max(Val.sec, p.sec);6 行未改动signed main(){ n = read(), m = read(); for(reg int i = 1;i <= m;i = -~i) link[i] = {read(), read(), read(), 0};
sort(link + 1, link + m + 1, Sort); for(reg int i = 1;i <= n;i = -~i) fa[i] = i, sze[i] = 1; for(reg int i = 1;i <= m;i = -~i) {13 行未改动 } // ------------------------ Kruscal memset(fa, 0, sizeof fa); memset(sze, 0, sizeof sze); // pre for chain
get_son(1 , 1); get_chain(1, 1); build(1, 1, n);
15 行未改动