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

求高手解答记录路径为何这样改就ac了?

Posted by uuisafresh at 2013-12-06 22:38:21 on Problem 1734
同样是fa[i][j]=i;当松弛时遇到d[i][j]>d[i][k]+d[k][j]把d松弛了然后
fa[i][j]=fa[k][j];
第一种寻找路径:
   int f = i;
   path[index++]=f;
   while(f!=fa[p][j]){f=fa[p][j];path[index++]=f:}
   path[index++]=j;
   path[index++]=k;

第二种寻找路径:
int f=j;
 while(f!=i){path[index++]=f;f=fa[f][j];}
path[index++]=i;
path[index++]=k;

前者WA,后者AC,为何?

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