Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
菜鸟::请问错在哪儿??#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator