摘要:
1.Prim算法(POJ2560)const maxn=101;var x,y,mindis:array[0..maxn] of extended; dis:array[0..maxn,0..maxn] of extended; vis:array[0..maxn] of boolean; n,i,j:longint; function calc(a,b:longint):extended; begin calc:=sqrt(sqr(x[a]-x[b])+sqr(y[a]-y[b])); end; procedure prim(root:longint); var i,j,k:longint;
阅读全文
posted @ 2011-08-07 20:18
exponent
阅读(246)
推荐(0)
编辑
摘要:
1.Dijkstra算法.(O(N^2)的算法就不写了,贴个堆优化的Dijkstra.)type node=record u,d:longint;end;const maxn=30001; maxm=400001; oo=1<<30;var n,m,s,t,cnt,size,u,v,w,i,j:longint; e:array[0..maxm] of record v,n,w:longint; end; l,d:array[0..maxn]...
阅读全文
posted @ 2011-08-07 20:11
exponent
阅读(276)
推荐(0)
编辑