Advertisement
aarjay

Untitled

Nov 1st, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1.  
  2.  
  3. 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.
  4. 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
  5. prelims contest. For that, they have decided to have a practice round before the prelims. They are going to have the practice
  6. round from time S to E. However, the team members are not so sure whether they would be able to participate in
  7. the practice contest for the whole duration as they already have some previous reservations. To solve that, they have created a list
  8. of all the things everyone is supposed to do or reservations they have to fulfill.
  9.  
  10. The list they prepared has a total of
  11. 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, atleast one of the team members is busy doing that task and would be unavailable for the ICPC pre-prelims practice contest.
  12.  
  13. 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.
  14. 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.
  15. Input
  16.  
  17. The first line of the input contains an integer T, the number of test cases in a file.
  18.  
  19. Then T test cases follow each of which has the following structure:
  20.  
  21. The first line of each test case contains two space separated integers S and E.
  22.  
  23. The second line of each test case contains N. Then N lines follow each of which contains two space separated integers,
  24. xi and yi, the start and the end time of the ith task.
  25. Output
  26.  
  27. 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.
  28. Constraints
  29.  
  30. 1 ≤ T ≤ 3
  31. 1 ≤ N ≤ 105
  32. 1 ≤ S < E ≤ 1018
  33. 1 ≤ xi < yi ≤ 1018
  34.  
  35.  
  36. Example
  37.  
  38. Input:
  39. 1
  40. 10 20
  41. 3
  42. 1 10
  43. 21 50
  44. 30 33
  45.  
  46. Output:
  47. YES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement