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

Re:WA 的朋友,可以看看叶子节点判断是否正确

Posted by 302536811 at 2014-01-04 18:01:22 on Problem 1145
In Reply To:WA 的朋友,可以看看叶子节点判断是否正确 Posted by:zhangfeifei at 2010-08-06 20:26:07
> 注意判断叶子节点,两棵空树是不是同一个节点的子树。这样才能准确判断叶子节点。
> !lChild && !rChild && high==rHigh 高度相同的连续两棵空树,对应的父节点一定是叶子节点,而高度不同的连续两棵空树却不能找到叶子节点。
> input:
> 22 (5(4(11(7()())(2()()))()) (8(13()())(4()(1()()))))
> 20 (5(4(11(7()())(2()()))()) (8(13()())(4()(1()()))))
> 10 (3 
>      (2 (4 () () )
>         (8 () () ) )
>      (1 (6 () () )
>         (4 () () ) ) )
> 0 ()
> -6 (3(-9()())())
> 9 (5(4(3(2()())())())())
> output:
> yes
> no
> yes
> no
> yes
> no

太感谢你第六组数据了

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