Editorial for IOI '14 P1 - Rail
Submitting an official solution before solving the problem yourself is a bannable offence.
Way: Ad Hoc
Query complexity:
Time complexity:
** This problem can be solved by the following steps:
First, we know that station
Second, we sort all the
Third, we process each station one by one according to their shortest distance with station
3.1 First, we maintain the information (location,id)
of the leftmost C type and the rightmost D type as the algorithm proceeds.
3.2 To process the current station query(k,leftmost C type)
as query(k, rightmost D type)
as
For example, we have only 4 cases to consider:
a. dis[k][L] is a direct route
( ) )
L k R
b. dis[k][L] is a direct route
( ) )
L R k
c. dis[k][R] is a direct route
( ( )
k L R
d. dis[k][R] is a direct route
( ( )
L k R
By careful analysis (some if/else conditions), we can get the answer. Sometimes, we may need extra information to resolve the four cases, where we can check with
Take case (a) for example:
a. dis[k][L] is a direct route
( ) )
L k R
the location of
a.1
( ( ) )
L p k R
There might be some
Comments