Editorial for IOI '95 P5 - Street Race
Submitting an official solution before solving the problem yourself is a bannable offence.
The data structure for a course is as follows:
CONST Max_Arrows = 100;
VAR number_of_points,number_of_arrows : INTEGER;
    Arrows : ARRAY [0..Max_Arrows-1,0..1] OF INTEGER;
The number of the start point is , the number of the finish point is 
. The 
 arrow 
 goes from the point with number 
 to the point with number 
.
The data structure for the solution of the task is as follows:
CONST Max_points = 50;
TYPE Point_array = ARRAY [0..Max_points-1] OF BOOLEAN;
VAR number_unavoidable_points,number_splitting_points : INTEGER;
    unavoidable,splitting : Point_array;
number_unavoidable_points is the number of unavoidable points (apart from the start point and the finish point). number_splitting_points is the number of splitting points. unavoidable[N] is TRUE iff the point with number  is an unavoidable point. 
splitting[N] is TRUE iff the point with number  is a splitting point.
The main body of the program is:
BEGIN
  initialisation;
  read_input;
  compute_results;
  write_output;
  finalisation;
END.
The procedure initialisation initialises the variables mentioned above and file variables for input and output. The procedure read_input reads the input; the variables of the data structure for the course receive their final value. The procedure compute_results computes the results; the variables of the data structure for the solution of the task receive their final value. The procedure write_output writes the output to the appropriate file. The procedure finalisation closes the files.
We will only consider the procedure compute_results from here, as the implementation of the other procedures is straightforward.
The procedure compute_results determines for each point (except start point and finish point) whether it is an unavoidable point, and if so, whether it is a splitting point (Note that each splitting point is an unavoidable point as well).
To determine whether current_point is an unavoidable point, determine the set  of all points which can be reached from the start point via a path which does not contain 
current_point. Obviously, current_point is an unavoidable point iff the finish point is not in .
 is determined by calling the procedure 
find_reachable with current_point as the argument. The result is stored in the Point_array reachable. After the call find_reachable(current_point), the value of reachable[N] is TRUE iff point  can be reached from the start point via a path which does not contain 
current_point. By definition, reachable[current_point] is FALSE. Careful analysis now shows that current_point is a splitting point iff there is no arrow from a point  with 
reachable[P] = FALSE to a point  with 
reachable[Q] = TRUE. This can be checked by a function.
Comments