
并查集
lp_opai
我没有时间写一封简短的信,所以我写了一封长的。
展开
-
Hdu-3926 Hand in Hand(同构图)
原博客:转载 2014-07-16 18:30:37 · 479 阅读 · 0 评论 -
hdu 3172Virtual Friends (map水过)
# include # include //不能sting.h# include # include # includeusing namespace std;int father[200010];int num[200010];int find(int x){ if(x==father[x]) return x; return father[x]=find(father原创 2014-07-17 15:13:47 · 678 阅读 · 0 评论 -
hdu 3635 Dragon Balls ( 并查集路径压缩)
# include # include using namespace std;int father[10010];int cot[10010];int num[10010];int find(int x){ if(x==father[x]) return x; else { int p=father[x]; father[x]=find(father[x]);//原创 2014-07-18 21:58:15 · 567 阅读 · 0 评论 -
hdu 3047 Zjnu Stadium (带权并查集)
# include # include using namespace std;int father[50010];int dis[50010];int fa,fb;int find(int x){ if(x!=father[x]) { int p=father[x]; father[x]=find(father[x]); dis[x]+=dis[p]; } re原创 2014-07-19 19:07:24 · 552 阅读 · 0 评论 -
hdu 1325 &&poj1308 Is It A Tree?
//构成一棵树 1:不成环// 2:只有一个入度为零的根节点,其他入度为1// 没有节点为空树# include # include using namespace std;int father[100010];int vis[10010];int into[100010];int find(int x){ if(x==father[x])原创 2014-07-13 15:44:28 · 623 阅读 · 0 评论 -
HDU 1811 Rank of Tetris
# include # include # include # include using namespace std;int father[10010],r[20005],l[20005],into[10010],n;char ch[20005];int find(int x){ if(x==father[x]) return x; return father[x]=fi原创 2014-07-15 09:29:31 · 581 阅读 · 0 评论 -
hdu 1198 Farm Irrigation (并查集)
# include # include using namespace std;int father[3000];int map[55][55][5];int find(int x){ if(x==father[x]) return x; return father[x]=find(father[x]);}int s[15][4]={{1,0,1,0},{1,0,0,1},原创 2014-07-14 15:42:10 · 532 阅读 · 0 评论 -
poj 1456 Supermarket (贪心+并查集)
# include # include # include using namespace std;int fa[10010];struct node{ int p; int d;};struct node a[10010];bool cmp(node a1,node a2)//利润从大到小{ return a1.p>a2.p;}int find(int x){原创 2014-08-03 10:02:43 · 842 阅读 · 0 评论 -
hdu 4424 Conquer a New Region (并查集)
///题意:给出一棵树,树的边上都有边权值,求从一点出发的权值和最大,权值为从一点出去路径上边权的最小值# include # include # include # include using namespace std;# define MAX 200010struct node{ int u,v; int w;};struct node a[MAX];_原创 2014-10-19 22:32:49 · 723 阅读 · 0 评论