CENS20F - Editorial

Same problem as this

1 Like

@aert My bad, I thought the inputs would directly give me a directed tree. I just corrected that. And, it passes for the above test case, yet it still cannot pass the submission. Could you please provide a test case for where it fails

@aert , could you please tell me where I am going wrong
My submission - CodeChef: Practical coding for everyone
1
3 1
1 1 1
3 2
2 1
1
1

It has been a few hours now!
@aert , could you help me out?

I am not sure how you are keeping track of the visited nodes using the map but here is a case on which your solution fails
1
4 2
6 2 7 3
1 2
2 3
3 4
1
2
Node 3 is being marked as visited so the query from node 2 is unable to reach node 4.

Another potential problem is that you are not marking the source node as visited. If the input is star shaped, for each query you will end up visiting all its neighbours.

1 Like

Can you kindly tell me sir, what is your complexity per query? I feel it is O(n*q) which amounts to 10^10 operations that should not pass in a 1.5 s time limit…
If you can kindly address this doubt or anyone else out here…
thanks in advance

could you please tell how you are generating so many test cases, just by thinking or you have used some kind of generators or something?