最短路
dijkstra演算法----模版:
hdoj:
#include"stdio.h"
#include"string.h"
#define max 99999
int road[110][110],i,j,k,s[110],dist[110];
int n,m;
void dijkstra(int begin)
}}int main()
{ int a,b,t;
while(scanf("%d%d",&n,&m),n!=0&&m!=0)
{for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
road[i][j]=max;
for(i=0;i
HDOJ 2544 最短路 最短路
最基礎的單源最短路徑 dijkstra 複雜度o n 2 include include include include include include include include include include include include include include include i...
Dijkstra 最短路徑
dijkstra 最短路徑 針對有向圖,不支援負權值 圖的相鄰矩陣表示方法,還要用到最小值堆 include include define unvisited 0 define visited 1 define infinite 9999 設定最大值 define n 5 定義圖的頂點數 using...
dijkstra最短路徑
hehe和xixi在乙個地方玩遊戲,xixi把n 1件禮物 hehe以前送給xixi的 分別藏在了另外n 1個地方,這些地方都能互相到達,且所有的邊都是有方向的。現在hehe要做的事就是去那些地方找回那n 1件禮物給xixi 由於每一件禮物都有特殊的意義,所以xixi要求hehe每找到一件禮物,就必...