ICPC Pre-Prelims Practice Round
All submissions for this problem are available.
Like all other teams, the LaZyProblemSetters (consisting of V, J and S) are also participating in ICPC with high hopes for qualifying for the world finals. They would like to go to the world finals to represent their country and bring back a medal. However, first they have to clear the prelims contest. For that, they have decided to have a practice round before the prelims. They are going to have the practice round from time S to E. However, the team members are not so sure whether they would be able to participate in the practice contest for the whole duration as they already have some previous reservations. To solve that, they have created a list of all the things everyone is supposed to do or reservations they have to fulfil.
The list they prepared has a total of N tasks. They have also noted down the time in which each task needs to be done, i.e. the start time and the end time. During that time, at least one of the team members is busy doing that task and would be unavailable for the ICPC pre-prelims practice contest.
You are given the time slot LaZyProblemSetters have decided to practice together and the list of tasks with their start and end time that they prepared. Print whether they all would be able to practice together for the full duration of the contest. For this problem, you can assume that if V, J or S ends a task at time T1, he can give his undivided attention to the contest starting from T1 itself and if the contest ends at time T2, they can get back to their reserved tasks at T2 itself.
The first line of the input contains an integer T, the number of test cases in a file.
Then T test cases follow each of which has the following structure:
The first line of each test case contains two space separated integers S and E.
The second line of each test case contains N. Then N lines follow each of which contains two space separated integers, xi and yi, the start and the end time of the ith task.
For each test case, print "YES" (without quotes) if the team members can practice together for the full duration of the pre-prelims contest, print "NO" (without quotes) otherwise in a new line.
- 1 ≤ T ≤ 3
- 1 ≤ N ≤ 105
- 1 ≤ S < E ≤ 1018
- 1 ≤ xi < yi ≤ 1018
Input: 1 10 20 3 1 10 21 50 30 33 Output: YES
|Tags||acmkan14, admin, cakewalk, programming|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA|
Fetching successful submissions