Abednego wrote:I think you misunderstood the problem. How could your print 1 for the first test case?
Thanks for your kind reply, Abednego, Destination Goa !
I think this problem's task is to find the longest path (Minmax).
The n1 cockroaches move to other nests
(If their initial position are 0 and n==4, they move to 1 & 2 & 3).
They can use same trails with other cockroaches.
If they could't reach individual nests, their misson is failed.
They always choose the shortest path.
(If there are 1>3>2 (time==2) and 1>2 (time==1) paths, they choose 1>2 path (1<2).)
And, there will be no trails from a node to itself and no duplicate trails (thanks, Destination Goa).
3 3
2 1
1 0
2 0
Following is the image of above test case.
Code: Select all
++

 2 > 1
  
  
  v
 > 0

++
Initial position 0 :
they can't move, so the mission is failed.
Initial position 1 :
they can move only to '0', but they have to go '0' and '2', so the mission is failed.
Initial position 2 :
they can move to '0' and '1'. The shortest paths are 2>0 and 2>1.
Both length are 1, so the Emergency Response Time is 1.
Finally, from these results, the answer is 1.
.... but, my answer is wrong.
Could you tell me what's wrong ?
Best regards.