并查集
文章平均质量分 63
_夜风
我好懒怎么办
展开
-
hdu 1232
以前写的.....拿出来看看.... 并查集模板: #include #include using namespace std; int f[10000]; int find(int x) { if(f[x]==0) return x; return f[x]=find(f[x]); } int bing(int a,int b) { i原创 2014-12-10 22:56:13 · 504 阅读 · 0 评论 -
nyoj 42
#include #include #include #include using namespace std; int f[1000]; int digree[1000]; int find(int x) { while(x!=f[x]) x=find(f[x]); return x; } void bing(int a,int b) {原创 2014-12-11 17:27:38 · 462 阅读 · 0 评论