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

此题若用A*,h函数怎么设计?请过的人回答下

Posted by Kevin0602 at 2010-07-23 22:06:48 on Problem 1915 and last updated at 2010-07-23 22:15:27
我的g函数用的是已走的步数,然后加了下面注释中的条件题目就过不了(不加能过但速度不行)
if( board[next.x][next.y]==0 /*|| (board[next.x][next.y]==1 &&  cur.g+1<next.g)*/ ) 

我的h函数
inline int h(Node a)
{   
     return (int)floor(sqrt((double)(abs(a.x-end.x)*abs(a.x-end.x)+abs(a.y-end.y)*abs(a.y-end.y)))/sqrt(5.0)+0.0001);
     //return (int)ceil(double(abs(a.x-end.x)+abs(a.y-end.y))/3.0-0.000001);
}


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