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

菜鸟::请问错在哪儿??

Posted by swust20095862 at 2010-08-07 16:14:56 on Problem 3259
#include<stdio.h>
int map[2000][2000];
int begin,end,len;
main()
{
	int s;
	int N,M,T;
	int i,j,k;
	int max,min;
	scanf("%d",&s);
	while(s--)
	{
		scanf("%d%d%d",&N,&M,&T);
		for(i=1;i<=N;i++)
			for(j=1;j<=N;j++)
				map[i][j]=-1;
		for(i=1;i<=M;i++)
		{
			scanf("%d%d%d",&begin,&end,&len);
			if(map[begin][end]>len||map[begin][end]==-1)
			{
				map[begin][end]=len;
				map[end][begin]=len;
			}
		}
		for(k=1;k<=N;k++)
			for(i=1;i<=N;i++)
				for(j=1;j<=N;j++) 
					if(map[i][k]!=-1&&map[k][j]!=-1)
						if(map[i][j]==-1||map[i][j]>(map[i][k]+map[k][j]))
							map[i][j]=map[i][k]+map[k][j];
		while(T--)
		{
			scanf("%d%d%d",&begin,&end,&min);
            if(map[begin][end]!=-1&&map[begin][end]<min)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	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