I am working on UVa # 112 Tree Summing . I have something that, in my opinion, should be a working solution, but it is not accepted by the online judge due to a basic misunderstanding of the problem on my part. Consider the following inputs:
-1 (-1()())
77 (77(1()())())
or schematically, the trees look like this:
-1 77
/ \ / \
() () 1 ()
/ \
() ()
According to at least two working solutions, the correct conclusion is for the above inputs:
yes
no
However, I do not understand why the second should be "no." It seems to me that the rightmost path of the tree should give the correct amount. What am I missing?
source
share