LCT 維護邊雙 點雙的模板

2022-05-04 13:48:13 字數 1312 閱讀 6040

用 \(\text\) 維護邊雙的做法是:加入一條非樹邊時,將這段樹上路徑合併為乙個點代表這個邊雙,具體實現用並查集合並點,在 \(\text\) 與 \(\text\) 的過程中對輔助樹上父親做路徑壓縮。

用 \(\text\) 維護點雙的做法是:加入一條非樹邊時,將這段樹上路徑全部砍斷,新建乙個點代表這個點雙,將原來那些點向新點連虛邊。

實現方法:直接用 \(\text\) 與 \(\text\) 提取路徑並且 \(\text\) 遍歷這個路徑就可以了。

**是維護路徑橋與割點的個數。 洛谷鏈結

#includeusing namespace std;

const int n = 200005;

int n,q,lst;

struct bcj

int find(int x)

}g;namespace lct

int nrt(int x)

void pushup(int x)

void pushdown(int x) }

void rot(int x)

void splay(int x)

void access(int x) }

void makeroot(int x)

void link(int x, int y)

void dfs_merge(int x, int root)

void zip(int x, int y)

int query(int x, int y)

#undef lc

#undef rc

#undef f

}namespace rst

int nrt(int x)

void pushup(int x)

void pushdown(int x) }

void rot(int x)

void splay(int x)

void access(int x) }

void makeroot(int x)

void link(int x, int y)

void dfs_merge(int x, int root)

void zip(int x, int y)

int query(int x, int y)

#undef lc

#undef rc

}int main()

if(opt == 2)

if(opt == 3)

}return 0;

}

Tarjan縮點 邊雙 點雙

目錄 1.poj 3694 network 2.2019 icpc 橫濱站 3.p3225 hnoi2012 礦場搭建 4.一本通 分離的路徑 所以其實就三個玩意 1.dfn,low,indx 2.stacks,bool pd 3.scc,scnt,col等我們要求的資訊 變數名 用處 dfn 記錄...

點 邊 雙聯通分量1 1

點 include include include include include includeusing namespace std const int maxn 1000 10 int n,m int bcc cnt int dfs clock bcc cnt計數一共有多少個點 雙連通分量 i...

JZOJ5465 道路重建 邊雙縮點 樹的直徑

lueluelue 這鬼題卡了我10發提交,之前做過一道類似的題目 題解p2860 usaco冗雜路徑 縮點 橋 危險的邊就是橋邊,tarjan求出邊雙后縮點整個圖變成樹,樹邊都是危險的邊,我們需要加一條邊構成乙個新的ecc使危險的邊最小 於是一開始naiive的以為求出所有葉子節點判一判就好了,於...