July cook off PATHETIC wrong ans

question:CodeChef: Practical coding for everyone

Solution :CodeChef: Practical coding for everyone

Can you explain your code’s idea? You are also getting Wrong answer for 1st testcase of sample input.

Your solution is getting wrong answer because it is not correct.
It seems like your solution builds up an adjacency-list. But then ignores it and prints the numbers 1 to n. This would work if all vertices were in a straight line, in the right order, but here we are dealing with trees. As an example a tree where it would not work:

  2---4
 /
1---3---5

The bottom path consists of at least two vertices, none of which are divisble by two. So their product will not be either.

If you get stuck you might want to take a look at the editorial.

so sorry can you please check this out again i posted a different solution

please check the post (solution) again . Sorry Previos was posted mistakenly.

max2 > 2*10^{18}
max2 =3749562977351496827
limit =2000000000000000000
Use this method to generate max1 and max2

That one seems much closer. I think the problem is that max2 is too large. Could you add a debug statement checking the value of max2?

The editorial itself doesn’t list a method of making max and max2 the correct values, but it can be found in the replies to the editorial