#arc106c. [arc106_c]Solutions
[arc106_c]Solutions
Problem Statement
Two segments \[L_1:R_1\] and \[L_2:R_2\] are said to intersect when and holds.
Consider the following problem :
Input: segments \[L_1: R_1\], \\cdots, \[L_N:R_N\] are pairwise distinct. Output: the maximum number of segments that can be chosen so that no two of them intersect.
Takahashi has implemented a program that works as follows:
Sort the given segments in the increasing order of and let the result be $\[L_{p_1}:R_{p_1}\], \[L_{p_2}:R_{p_2}\], \\cdots , \[L_{p_N}:R_{p_N}\]$. For each , do the following: Choose \[L_{p_i}:R_{p_i}\] if it intersects with none of the segments chosen so far. Print the number of chosen segments.
Aoki, on the other hand, has implemented a program that works as follows:
Sort the given segments in the increasing order of and let the result be $\[L_{p_1}:R_{p_1}\], \[L_{p_2}:R_{p_2}\], \\cdots , \[L_{p_N}:R_{p_N}\]$. For each , do the following: Choose \[L_{p_i}:R_{p_i}\] if it intersects with none of the segments chosen so far. Print the number of chosen segments.
Given are integers and . Construct an input for the problem , consisting of segments, such that the following holds:
$$(\\text{The value printed by Takahashi's program}) - (\\text{The value printed by Aoki's program}) = M $$Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there is no set of segments that satisfies the condition, print -1
.
Otherwise, print lines as follows:
Here, \[L_1:R_1\], \\cdots, \[L_N:R_N\] must satisfy the following:
- ()
- ()
- are integers (21:46 added)
If there are multiple answers, any of them will be accepted.
Be sure to print a newline at the end of the output.
Sample Input 1
5 1
Sample Output 1
1 10
8 12
13 20
11 14
2 4
Let us call the five segments Segment , Segment , , Segment .
Takahashi's program will work as follows:
Rearrange the segments into the order Segment , Segment , Segment , Segment , Segment . Choose Segment . Skip Segment (because it intersects with Segment ). Choose Segment . Skip Segment (because it intersects with Segment ). Choose Segment .
Thus, Takahashi's program will print .
Aoki's program will work as follows:
Rearrange the segments into the order Segment , Segment , Segment , Segment , Segment . Choose Segment . Skip Segment (because it intersects with Segment ). Skip Segment (because it intersects with Segment ). Choose Segment . Skip Segment (because it intersects with Segment ).
Thus, Aoki's program will print .
Here, we have , and thus these five segments satisfy the condition.
Sample Input 2
10 -10
Sample Output 2
-1