#K61177. Check Schedule Conflicts

    ID: 31252 Type: Default 1000ms 256MiB

Check Schedule Conflicts

Check Schedule Conflicts

You are given a list of schedules, each with a start time and an end time in the format HH:MM. Your task is to determine whether any two schedules overlap. Two schedules are said to overlap if the end time of one is greater than the start time of a subsequent schedule when the schedules are sorted by start time.

Formally, if the schedules (after sorting) are \( [s_1,e_1], [s_2,e_2], \ldots, [s_n,e_n] \), then a conflict exists if there exists an index \( i \) (\( 1 \leq i < n \)) such that:

\( e_i > s_{i+1} \)

Output OVERLAP if any two schedules overlap, otherwise output NO OVERLAP.

inputFormat

The first line contains a single integer ( n ) representing the number of schedules. Each of the next ( n ) lines contains two strings separated by a space: the start time and the end time in the format HH:MM.

outputFormat

Output a single line containing either "OVERLAP" if there is any conflict or "NO OVERLAP" if there is no conflict.## sample

3
06:00 07:00
07:00 08:00
08:00 09:00
NO OVERLAP