#P10793. 『SpOI - R1』Double Champions
『SpOI - R1』Double Champions
Problem Description
This problem contains multiple test cases.
Now there are several cells arranged in a line.
You are given intervals. Each interval can cover every cell in the range (for example, the interval can cover cells ).
Now you need to group these intervals. The contribution of each group is the total length of the intersection of all intervals in that group.
You need to find the minimum number of groups to split these intervals into, such that the contribution of every group is . If there is no solution, output No.
Input Format
The first line contains an integer , the number of test cases.
For each test case, the first line contains two integers .
The next lines each contain two integers , describing an interval.
Output Format
For each test case, output one line with the answer: the minimum number of groups, or the string No if there is no solution.
2
5 3
6 10
6 8
3 5
7 9
1 9
5 5
5 10
3 8
6 10
4 10
5 9
3
3
Hint
Explanation for Sample #1
Number the intervals in the input order as .
The intervals can be divided into the following groups: . Then the contribution of each group (i.e., the intersection size) is respectively, which satisfies the requirement that each group’s contribution is . It can be proven that among all valid partitions, groups is the minimum.
Constraints
Please pay attention to the impact of constant factors on program efficiency.
This problem uses bundled testdata and subtask dependencies.
For of the testdata, , , , .
| Subtask | Score | Subtask Dependencies | ||
|---|---|---|---|---|
| 1 | None | |||
| 2 | 1 | |||
| 3 | 1,2 | |||
| 4 | 1,2,3 |
Translated by ChatGPT 5