#K36007. Train Timetable Scheduling
Train Timetable Scheduling
Train Timetable Scheduling
In this problem, you are given the schedule for (n) trains. Each train is assigned a track and has specified arrival and departure times in HH:MM format. Your task is to generate a feasible daily train timetable ensuring that there are no conflicts on the same track. A conflict occurs if a train's arrival time is earlier than the departure time of a previously scheduled train on the same track. If any conflict is detected on any track, output (Scheduling\ Impossible). Otherwise, output the timetable with each line formatted as ((Train\ i) [arrival\ - departure]), where (i) is the train's original order from the input. Note that the trains for each track should be sorted by their arrival times.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n) ((0 \le n \le 10^5)), the number of trains. Each of the next (n) lines contains three items separated by spaces: an integer representing the track number, a string representing the arrival time in HH:MM format, and a string representing the departure time in HH:MM format.
outputFormat
The output is printed to standard output (stdout). If scheduling is possible, print (n) lines with each line in the format ((Train\ i) [arrival\ - departure]) corresponding to each train. If any conflict exists, print a single line with the text (Scheduling\ Impossible). In the case of (n = 0), no output is produced.## sample
3
1 09:00 09:45
1 09:50 10:30
2 09:00 09:30
(Train 1) [09:00 - 09:45]
(Train 2) [09:50 - 10:30]
(Train 3) [09:00 - 09:30]
</p>