摘要:
http://codevs.cn/problem/3728/我们要做的是计算距离为2的有序对权值之和及最大值,最大值好弄,但一一枚举是不可行的,因为na then begin b:=a; a:=x; end else if x>b then b:=x;end;begin rea... 阅读全文
posted @ 2015-05-17 20:57
no regrets
阅读(214)评论(0)推荐(0)
编辑
摘要:
次小生成树定义设G=(V,E)是连通的无向图,T是图G的一个最小生成树。如果有另一棵树T1,T1T,满足不存在树T’,T’T,w(T’)y then BeginU:=head[x];While u-1 doBegin V:=head[y]; While v-1 do Begin Length[lin... 阅读全文
posted @ 2015-05-05 12:50
no regrets
阅读(225)评论(0)推荐(0)
编辑
摘要:
最小生成树Kruskal算法//使用并查集,基本操作略Quick_sort(1,m); //对边按权值排序For i:=1 to m doBegin X:=father(e[i].a); Y:=father(e[i].b); If xy then BeginUnion(x,y);Inc(k);E[i... 阅读全文
posted @ 2015-05-05 12:49
no regrets
阅读(74)评论(0)推荐(0)
编辑
摘要:
使用链式前向星储存边,代码如下://先将图中没有前驱(即入度为0)的顶点加入队列For i:=1 to n do if d[i]=0 thenBegin Inc(tot); q[tot]:=i;End;//使用队列中的点更新d数组并生成拓扑序列Iq:=0;While iq-1 doBegin Dec... 阅读全文
posted @ 2015-05-05 12:48
no regrets
阅读(79)评论(0)推荐(0)
编辑
摘要:
数据结构:Type EdegNode=recordT,w,next:longint; End;VarE:array[1..m]of longint;Head:array[1..n]of longint;读入边:For i:=1 to n do head[i]:=-1;For i:=1 to m do... 阅读全文
posted @ 2015-05-05 12:47
no regrets
阅读(378)评论(0)推荐(0)
编辑