| ||||||||||
| 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 | |||||||||
求高手解答记录路径为何这样改就ac了?同样是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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator