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 |
我的思路如下,各位大牛帮忙看看,总是WA根据输入存储每个节点的祖先: tree[j]=k表示节点j的祖先是k。 查询a跟b的LCA:先分别求出a跟b到根节点的路径,然后比较这两条路径得出LCA。 这样的算法可以吗?数据会不会跟描述的不同?N最大可以多大? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator