Блог пользователя naivedyam

Автор naivedyam, история, 5 часов назад, По-английски

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?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится