8VC Venture Cup 2017 - Elimination Round
E
PolandBall and White-Red graph
Codeforces
2400
原题
← DF →
翻译中…

PolandBall has an undirected simple graph consisting of $*n*$ vertices. Unfortunately, it has no edges. The graph is very sad because of that. PolandBall wanted to make it happier, adding some red edges. Then, he will add white edges in every remaining place. Therefore, the final graph will be a clique in two colors: white and red.

翻译中…

Colorfulness of the graph is a value $*min*(*d*_{*r*}, *d*_{*w*})$, where $*d*_{*r*}$ is the diameter of the red subgraph and $*d*_{*w*}$ is the diameter of white subgraph. The diameter of a graph is a largest value $*d*$ such that shortest path between some pair of vertices in it is equal to $*d*$. If the graph is not connected, we consider its diameter to be -1.

翻译中…

PolandBall wants the final graph to be as neat as possible. He wants the final colorfulness to be equal to $*k*$. Can you help him and find any graph which satisfies PolandBall's requests?

翻译中…

Input

翻译中…

The only one input line contains two integers $*n*$ and $*k*$ ($2 ≤ *n* ≤ 1000$, $1 ≤ *k* ≤ 1000$), representing graph's size and sought colorfulness.

翻译中…

Output

翻译中…

If it's impossible to find a suitable graph, print -1.

翻译中…

Otherwise, you can output any graph which fulfills PolandBall's requirements. First, output $*m*$ — the number of red edges in your graph. Then, you should output $*m*$ lines, each containing two integers $*a*_{*i*}$ and $*b*_{*i*}$, ($1 ≤ *a*_{*i*}, *b*_{*i*} ≤ *n*$, $*a*_{*i*} ≠ *b*_{*i*}$) which means that there is an undirected red edge between vertices $*a*_{*i*}$ and $*b*_{*i*}$. Every red edge should be printed exactly once, you can print the edges and the vertices of every edge in arbitrary order.

翻译中…

Remember that PolandBall's graph should remain simple, so no loops or multiple edges are allowed.

翻译中…

Note

翻译中…

In the first sample case, no graph can fulfill PolandBall's requirements.

翻译中…

In the second sample case, red graph is a path from $1$ to $5$. Its diameter is $4$. However, white graph has diameter $2$, because it consists of edges 1-3, 1-4, 1-5, 2-4, 2-5, 3-5.

翻译中…

样例

Input #1
4 1
Output #1
-1
InputCopy OutputCopy
Input #2
5 2
Output #2
4
1 2
2 3
3 4
4 5
InputCopy OutputCopy
题目信息
题号
755E
时间限制
2 s
内存限制
256 MB
标签
构造
图论
最短路

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