标签: 模板

1 篇文章

并查集模板
int pre[N]; //递归方式 int find_1(int x) { if(pre[x]!=x) pre[x]=find(pre[x]); return pre[x]; } //非递归方式 int find_2(int x) { if(pre[x]!=x) while(pre[x]!=pre[pre[x]]) pre&…