Full Binary Tree Example
There is a full binary tree of size . Recall that a full binary
tree is a binary tree in which every node has either
or children.
Let denote the root
of . Note that
qualifies as a full
binary tree if and only if it is rooted at . Let be a function which takes a node
and returns the median
of the sizes of the subtrees of if were rooted at instead. Recall that the median of
a list of even size is the mean of the 2 middle elements.
For example, in the illustrated example, . , since has two subtrees of sizes
and , the median of which is
. , since the tree rooted at
node has 3 subtrees,
of sizes , , and .
A subset of the nodes of
is chosen with
. You
are given the list and you have to determine
whether is in
.
Input
The first line consists of an integer (), the size of . The second line consists of
integers, the outputs
of on each node in
. It is guaranteed that
a valid full binary tree was used in generating test data
for this problem.
Output
Print “yes” if is
in and “no” if
is not in . If you cannot determine whether
is in from the given information, print
“impossible”.
Sample Input 1 |
Sample Output 1 |
2
1 2
|
yes
|
Sample Input 2 |
Sample Output 2 |
4
1 2 6 6
|
no
|