摘要: 1 #include 2 #include 3 4 int f[1001], g[1001]; 5 6 int find(int x) //并查集的查找,找到共同的父亲 7 { 8 if (f[x] != x) 9 f[x] = find(f[x]); 10 return f[x]; 11 } 12 13 in... 阅读全文
posted @ 2017-07-20 19:11 ouyang_wsgwz 阅读(140) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int M = 100005; 8 int a, b; 9 int father[M]; //记录父节点 10 bool circle; //判断是否存在环 11 bool visit... 阅读全文
posted @ 2017-07-20 16:18 ouyang_wsgwz 阅读(124) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 #define MAXN 5000 9 int fa[MAXN]; //父节点 10 int Rank[MAXN]; //数的高度 11 int ans; 12 13 void init(i... 阅读全文
posted @ 2017-07-20 10:35 ouyang_wsgwz 阅读(98) 评论(0) 推荐(0)