#K74922. Complement Intervals
Complement Intervals
Complement Intervals
Given a list of time intervals during a day, your task is to determine the free time slots that are not covered by any of the intervals. The day is represented as the interval \([0,1440)\) in minutes. Note that the provided intervals may overlap or be adjacent.
If there is any gap between the intervals, output each free interval on a separate line as two integers representing the start and end of the free slot. If the entire day is covered by the intervals, output No free interval
.
inputFormat
The first line of input is an integer n (0 ≤ n ≤ 1000), the number of intervals. The next n lines each contain two space-separated integers a and b (0 ≤ a < b ≤ 1440) representing an interval [a, b].
outputFormat
If there is any free interval, output each interval on a new line as two space-separated integers (start and end). If no free interval exists, output No free interval
instead.
3
0 100
150 300
1200 1440
100 150
300 1200
</p>