poj2472最短路spfa

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define ll long long
#define LL __int64
const ll INF=9999999999999;

using namespace std;

#define M 50010
#define inf 0xfffffff

//vector G[20002];
//vector> ::iterator iter;

//mapmp;
//map::iterator p;

int mp[500][500];
double dis[102];
int n,m;

void clear()
{
	memset(mp,0,sizeof(mp));
	memset(dis,0.0,sizeof(dis));
}

void spfa()
{
	queue q;
	while(!q.empty())
		q.pop();
	q.push(1);
	dis[1]=1;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int i=1;i<=n;i++)
		{

			if((dis[u]*(mp[u][i]*1.0/100))>dis[i])
			{
				dis[i]=dis[u]*(mp[u][i]*1.0/100*1.0);
					q.push(i);
			}
		}
	}
}

int main(void)
{
	while(scanf("%d",&n),n)
	{
		scanf("%d",&m);
		int u,v,w;
		clear();
		for(int i=0;i

你可能感兴趣的:(最短路)