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 |
ans的两个下标是节点id和用的money吗?In Reply To:似乎很接近阿,我的是这样的 Posted by:TN at 2005-05-18 17:48:32 > int bfs() > { > int i,j,p,qlen,qnow,end; > state now,ns; > init.node=1;init.cost=0;init.dis=0;len=0; > insert(init);ans[1][0]=0; > while (len>=1) > { > now=pop(); > if (now.node==n) return (now.dis); > for (i=1;i<=num[now.node];i++) > { > end=des[now.node][i]; > ns.node=end; > ns.dis=now.dis+dis[now.node][i]; > ns.cost=now.cost+cost[now.node][i]; > if (ns.cost<=k) > if (ns.dis<ans[end][ns.cost]) > { > ans[end][ns.cost]=ns.dis; > insert(ns); > } > } > } > return -1; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator