#C6846. Restaurant Reservation: Finding Available Slots

    ID: 50651 Type: Default 1000ms 256MiB

Restaurant Reservation: Finding Available Slots

Restaurant Reservation: Finding Available Slots

In this problem, you are asked to determine all available time slots for new reservations in a restaurant. The restaurant has fixed working hours given in 24-hour format (HH:MM), and there are several existing reservations. Each reservation is represented as a pair of times (start and end) both in HH:MM format.

Your task is to identify all time intervals during the working hours that are not covered by any reservation. Formally, if the working hours are given as \(T_{start}\) and \(T_{end}\), and the reservations as intervals \([R_{start}, R_{end}]\), you need to output all intervals \([S, E]\) such that each interval is a gap between the reservations or between the openings/closings and reservations. Note that time comparisons work lexicographically since the HH and MM fields are always zero-padded (e.g., "09:00" < "10:00").

Input/Output: The input is given via standard input and the output should be printed to standard output.

Example:

Input:
09:00 18:00
3
09:00 10:30
12:00 13:30
14:00 15:00

Output: 10:30 12:00 13:30 14:00 15:00 18:00

</p>

inputFormat

The input is provided via stdin in the following format:

<opening_time> <closing_time>
<N>
<reservation_1_start> <reservation_1_end>
<reservation_2_start> <reservation_2_end>
... (N lines total)

For example:

09:00 18:00
3
09:00 10:30
12:00 13:30
14:00 15:00

outputFormat

The output should display the available time slots, each on a new line. Each line contains two time stamps separated by a space representing the start and the end of an available slot. If there are no available slots, the output should be empty.

For the above sample, the output is:

10:30 12:00
13:30 14:00
15:00 18:00
## sample
09:00 18:00
0
09:00 18:00

</p>