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 |
似乎很接近阿,我的是这样的In Reply To:我的bfs这样写的 Posted by:00448264 at 2005-05-18 17:46:15 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