ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1314. Chase in Subway

any hints?
Posted by Tim Green 19 Apr 2004 13:39
Re: any hints?
Posted by Wendell 20 Apr 2004 15:17
Bellman-Ford
i got wa test 3
Posted by test 20 Apr 2004 15:22
Re: i got wa test 3
Posted by twotowers.bin 21 Apr 2004 00:39
I too

Edited by author 21.04.2004 00:39
Re: any hints?
Posted by Alone alone ! 22 Apr 2004 14:11
I used two SSSP algo (BFS + DFS) to solve the problem. Can it be done with only one ?
Re: any hints?
Posted by Thadeu Russo - UAM 22 Apr 2004 20:42
how to determinate the shortest route??? Why in the test input  the criminal goes to 85 and not to 10 or 75????
Just 2 BFSs.
Posted by Maigo Akisame (maigoakisame@yahoo.com.cn) 28 Oct 2004 08:34
First do BFS with the first node in the criminal's route. Save the result in the array d1. Do another BFS with the last node in the criminal's route, and save the result in the array d2. For any node i, if d1[i]-d2[i]=m-1, then i is an answer.

The graph is always connected.
Re: Just 2 BFSs.
Posted by Denis Koshman 1 Aug 2008 05:05
I build BFS traversal tree by giving priorities to points on the route (i.e. advance them first). Children of the last route node gain privelege for the rest of traversal (if you process nodes in the order they were first visited, this condition is automatic because they will be added prior to any other nodes during last privileged propagation).

After BFS tree is ready, nodes reachable from last node on the route inside that tree form the answer.

Edited by author 01.08.2008 05:09