Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

把min 设成0x7FFFFFFF,WA,改为0x7FFFFF,AC 为甚么啊,

Posted by ZJNU09220229 at 2010-10-30 17:09:34 on Problem 3268
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int f[1010][1010];
int g[1010][1010];
int D[1010],final[1010],a[1010];
int n,m,x;
int dijkstra(int x,int f[][1010])
{
	int i,j,k,min,ans;
	for(i=1;i<=n;i++)
	{
		D[i]=f[x][i];
		final[i]=0;
	}
	final[x]=1;
	for(i=2;i<=n;i++)
	{
		min=0x7FFFFFFF;
		for(j=1;j<=n;j++)
		if(D[j]<min&&!final[j])
		{
			k=j;
			min=D[j];
		}
		final[k]=1;
		for(j=1;j<=n;j++)
		if(!final[j]&&(min+f[k][j]<D[j]))
		D[j]=min+f[k][j];
	}
	return 0;
}
int main()
{
	int i,j,k,s,t,v,ans;
	while(scanf("%d%d%d",&n,&m,&x)!=EOF)
	{
		for(i=0;i<=n;i++)
		 for(j=0;j<=n;j++)
		g[i][j]=f[i][j]=0x7FFFFFFF;
		for(i=0;i<m;i++)
		{scanf("%d %d %d",&s,&t,&v);
		 if(f[s][t]>v)
		 f[s][t]=v;
		 if(g[t][s]>v)
		 g[t][s]=v;
		}
		memset(D,0,sizeof(D));
		for(i=1;i<=n;i++)
		f[i][i]=g[i][i]=0;
		  dijkstra(x,f);
		for(i=1;i<=n;i++)
              a[i]=D[i];
              memset(D,0,sizeof(D));
		dijkstra(x,g);
		for(i=1;i<=n;i++)
              a[i]+=D[i];
		ans=0;
		for(i=1;i<=n;i++)
		if(a[i]>ans) ans=a[i];
		printf("%d\n",ans);
	}
	return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator