标签:io for amp ef include c dijkstra 模板
#include <stdio.h>
#define N 205
#define INF 10000000
int g[N][N],bz[N],dist[N],s,t,n,m;
void Dijkstra(int s)
{ int i,j,min,k,x;
for (i=1;i<=n;i++)
{ dist[i]=g[s][i]; bz[i]=0; }
bz[s]=1;
for (i=1;i<n;i++)
{
min=INF;
j=s;
for (k=1;k<=n;k++)
if ( dist[k]<min && bz[k]==0 ) { min=dist[k]; j=k; }
bz[j]=1;
for (k=1;k<=n;k++)
if ( min+g[j][k]<dist[k] && bz[k]==0) dist[k]=min+g[j][k];
}
}
标签:io for amp ef include c dijkstra 模板
原文地址:http://www.cnblogs.com/2014acm/p/3905638.html