#C7743. Booking Conflict Checker

    ID: 51648 Type: Default 1000ms 256MiB

Booking Conflict Checker

Booking Conflict Checker

You are given a schedule of bookings, each defined by a start and an end time. A booking is represented as a half-open interval \([start, end)\) which means the booking includes the start time and excludes the end time. A new booking is given, and your task is to determine whether it conflicts with any of the existing bookings.

Two bookings \([s_1, e_1)\) and \([s_2, e_2)\) conflict if they overlap. In other words, the new booking \([new\_start, new\_end)\) conflicts with an existing booking \([start, end)\) if

[ new_start < end \quad \text{and} \quad new_end > start ]

If the new booking ends exactly when another booking starts, or starts exactly when another booking ends, they are considered non-overlapping.

Your program should be able to handle multiple test cases.

inputFormat

The input is given via standard input (stdin) and has the following format:

T
N
s1 e1
s2 e2
... (N lines)
new_start new_end
... (repeated T times)

Where:

  • T: Number of test cases (T > 0).
  • For each test case, the first line contains an integer N indicating the number of existing bookings. (N can be 0.)
  • The next N lines each contain two integers representing the start and end times of a booking.
  • The following line contains two integers representing the new booking's start and end times.

outputFormat

For each test case, output a single line to standard output (stdout):

  • Conflict if the new booking overlaps with any of the existing bookings.
  • No Conflict otherwise.
## sample
4
2
1 5
6 10
2 3
1
3 5
5 7
4
8 12
14 16
20 25
26 30
31 34
0
1 2
Conflict

No Conflict No Conflict No Conflict

</p>