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

这道题目的意图就是让你只用两次BFS

Posted by zhb_msqx at 2007-09-22 17:52:54 on Problem 3170
In Reply To:总是TLE...无语ing... Posted by:ice_lemon at 2007-03-04 22:28:17
首先把输入当中数值为4的节点保存起来,
初试化两个数组 a[],b[]值为INF
然后分别对start和end进行广搜,搜到4的节点时候记录步数,分别保存在a和b中
最后写一个for循环,a[i]+b[i]的最小值就是答案。

另外定义数组的时候最好动态初始化,免得会产生越界或者占用内存过大的麻烦。

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