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

我的思路如下,各位大牛帮忙看看,总是WA

Posted by felips at 2008-01-26 23:27:27 on Problem 1330
根据输入存储每个节点的祖先: tree[j]=k表示节点j的祖先是k。
查询a跟b的LCA:先分别求出a跟b到根节点的路径,然后比较这两条路径得出LCA。
这样的算法可以吗?数据会不会跟描述的不同?N最大可以多大?

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