What's Wrong with this solution?

Revision en1, by naivedyam, 2024-08-20 19:48:17

Can someone point out what's wrong with this solution 277417581? PS — I am neither good with trees nor with interactive problems. Had to submit it while reading the blog and learning from test cases. In the dry run it did pass for example 1 though but submitting it said "int 32 expected" while the problem clearly asked me to submit it after an ! mark. Also, if there is any flaw in the logic please point it out as well. My approach was I would take a as 1 and iterate it through all the values of b from 1 to n. Since it is a tree and not a graph, I believe every edge will be connected to either directly or through intermediate nodes. So if the query gives 1 I push back 1 and b else x and b because let's say the query gave x = 3, then 3 is connected to both 1 and 4 so we gotta pass both 1 3 and 3 4 but since I am iterating over all values of b, 1 3 should be there already so I just need to pass 3 4, am I on the right track?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English naivedyam 2024-08-20 19:48:17 985 Initial revision (published)