Input 1 2 0 Output YES 1 2 Expected Output NO
If the tree has multiple centers or centroids, then the beauty is the maximum among every possible pair.
For n=2, you cannot make centre and centroid co-incide for any tree. Beauty is the maximum among every possible pair. No matter what, beauty for n=2 will be 1, as there is only 1 tree possible for n=2.
EDIT- Next test case-
Input 1 4 1 Your Output YES 1 2 2 3 Expected Output YES 1 2 2 3 1 4
For n=2,centers are 1 and 2,and centroids also are 1 and 2.If we take center 1 and centroid 2, we get b=1 .So when n=2 ,b can have only one value,which is b=1 .It is peculiar case ,so should be handled separately.
You should take care that all 1 to n are connected.For some test cases the output is not not connected.They all should form single connected tree.
changed that part and updated my solution.But still getting wrong answer.
can you please give me example of one such test case in which my code fails.
Does your code work for-
1 4 1
Its printing 1 lines less afaik.
thanks a lot . But how did you came to know that this test case is not working.
Months of debugging codes gave me experience ^^