#P15555. [CCPC 2025 哈尔滨站] 比赛
[CCPC 2025 哈尔滨站] 比赛
Problem Description
The Cook Chicken Potato Contest is one of the most famous competitions in the chef world. The venue always provides stoves, and the organizer Little will divide the contestants into teams with the same number of people.
To test teamwork among contestants and make the contest more exciting, Little will arrange the teams so that the skill gaps among contestants in the same team are as large as possible. Suppose the contestants' skills are , and the teams they belong to are . Little defines the excitement of the contest as:
$$D=\mathop{\min}_{1 \le i < j \le n} \begin{cases} |a_i - a_j| & t_i = t_j \\ +\infty & t_i \neq t_j \end{cases}$$Now, possible contestants are given in nondecreasing order of skill. Since a contestant's skill is not fixed, the -th contestant is described by an interval , meaning their actual skill in a contest can be any real number in this interval. Also, because the contestants' skills are monotonic nondecreasing by index, it is guaranteed that for all , we have .
Little has contest plans. In the -th plan, contestants with indices between and will be invited. You need to help Little determine whether there exists a way to assign teams such that the contest excitement may be at least .
Input Format
This problem contains multiple test cases. The first line contains an integer (), indicating the number of test cases.
Then the test cases follow. For each test case:
The first line contains two integers and (, ), representing the number of possible contestants and the number of teams.
The next lines each contain two integers and (), describing the possible skill range of the -th contestant.
It is guaranteed that for all , and .
The next line contains an integer (), indicating the number of contest plans.
The next lines each contain three integers , , and (, , ), meaning that in the -th plan, contestants with indices from to will be invited, and Little expects the excitement to be .
It is guaranteed that over all test cases does not exceed , and does not exceed .
Output Format
For each test case, output lines. For the -th line, output YES or NO, indicating whether Little 's expected value for the -th plan may be achievable. You may output the answer in any letter case (uppercase or lowercase). For example, yEs, yes, Yes, and YES are all considered affirmative answers.
2
4 2
1 1
3 3
4 4
6 6
3
1 2 3
3 4 2
1 4 2
5 1
1 3
2 3
4 6
7 10
8 12
6
1 3 2
1 3 3
2 4 4
2 4 5
3 5 4
3 5 5
YES
YES
YES
YES
NO
YES
NO
YES
NO
Hint
Translated by ChatGPT 5