THOUSES, First two subtasks alone WA

I tried my best to resolve the WA on the first two subtasks :frowning:
Someone, please help me finding where I went wrong.
My code and the result is here

You assumed that the for edge (u, v), u will be parent of v. First two files had cases failing that.

See corrected code.

1 Like

Thanks so much @taran_1407 :smiley:

@taran_1407 i have considered this case also but still getting WA for 1st 2 cases but i have used bfs !
can give some hint why?

First I would like to suggest you that you should not cheat in any ogoing contest. So the mistake you need to avoid first is stop cheating. You have cheated in the question Valid Path.

You can generate some small random test cases where your solution would fail against the official one.

https://test-case-generator.herokuapp.com/
You can use this in case you don’t want to write the code for random generation of trees on your own.

1 Like

https://www.codechef.com/viewsolution/46609983
i have tried all cases but I am not getting where I am doing wrong can anybody suggest me where I am doing wrong (only first 2 cases) . thanks in advance …

In some of the long contests, I start with one or two problems and then due to college works or some other priorities I would’ve left them incomplete. So my rating graph looks soo irregular.

2 Likes