AtCoder Regular Contest 106
C
Solutions
AtCoder
⌀ 1225
原题
← BD →
翻译中…

Problem Statement

翻译中…

Two segments $[L_1:R_1]$ and $[L_2:R_2]$ are said to intersect when $L_1 \leq R_2$ and $L_2 \leq R_1$ holds.

翻译中…

Consider the following problem $P$:

翻译中…

Input: N segments [L_1: R_1], \cdots, [L_N:R_N]
       L_1, L_2, \cdots, L_N, R_1, R_2, \cdots, 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 R_i 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 i = 1, 2, \cdots , N, 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 L_i 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 i = 1, 2, \cdots , N, 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 $N$ and $M$. Construct an input for the problem $P$, consisting of $N$ 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.
  • $1 \leq N \leq 2 \times 10^5$
  • $-N \leq M \leq N$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

If there is no set of $N$ segments that satisfies the condition, print -1.

翻译中…

Otherwise, print $N$ lines as follows:

翻译中…

L_1 R_1
L_2 R_2
  \vdots
L_N R_N

翻译中…

Here, $[L_1:R_1], \cdots, [L_N:R_N]$ must satisfy the following:

翻译中…
  • $1 \leq L_i < R_i \leq 10^9$
  • $L_i \neq L_j$ ($i \neq j$)
  • $R_i \neq R_j$ ($i \neq j$)
  • $L_i \neq R_j$
  • $L_1, \cdots , L_N , R_1, \cdots , R_N$ 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.

翻译中…

样例

Input #1
5 1
Output #1
1 10
8 12
13 20
11 14
2 4
Let us call the five segments Segment $1$, Segment $2$, $\cdots$, Segment $5$. Takahashi's program will work as follows: Thus, Takahashi's program will print $3$. Aoki's program will work as follows: Thus, Aoki's program will print $2$. Here, we have $3 - 2 = 1 \left(= M \right)$, and thus these five segments satisfy the condition.
Input #2
10 -10
Output #2
-1
题目信息
题号
arc106_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。