随笔分类 -  数据结构——并查集

摘要:题目链接:http://acm.buaa.edu.cn/problem/418/代码:#include#include#include#includeusing namespace std;const int maxn = 550;const int maxe = 5050;const int INF = 0x3f3f3f3f;int pa[maxn];int find(int x){ return x == pa[x] ? x : pa[x] = find(pa[x]);}struct Edge{ int u,v,w; bool operator rhs.w; }}... 阅读全文
posted @ 2013-12-06 19:54 等待最好的两个人 阅读(146) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4750代码:#include#include#include#includeusing namespace std;const int maxn = 10005;const int maxm = 500500;struct Edge{ int u,v,w; Edge(int u=0,int v=0,int w=0): u(u), v(v), w(w) {} bool operator >n>>m) { for(int i=0; i<n; i++) ... 阅读全文
posted @ 2013-10-01 22:45 等待最好的两个人 阅读(198) 评论(0) 推荐(0)
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4882代码:#include#include#include#include#includeusing namespace std;const int maxn = 200005;struct Edge{ int u,v,w; Edge(int u=0,int v=0,int w=0): u(u), v(v), w(w) {} bool operator rhs.w; }}edges[maxn];int counts[maxn];int p... 阅读全文
posted @ 2013-10-01 20:37 等待最好的两个人 阅读(154) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1611#include #include #include #include #include #include #include #define maxn 30050#define INF 0x3f3f3fusing namespace std;int pa[maxn]; int find(int x){ return x == pa[x] ? x : pa[x] = find(pa[x]);}int main(){ int n,m; while(scanf("%d%d",&n,&m)){ . 阅读全文
posted @ 2013-07-31 21:14 等待最好的两个人 阅读(115) 评论(0) 推荐(0)