CF755E.PolandBall and White-Red graph

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

PolandBall has an undirected simple graph consisting of nn 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(dr,dw)min(d_{r},d_{w}) , where drd_{r} is the diameter of the red subgraph and dwd_{w} is the diameter of white subgraph. The diameter of a graph is a largest value dd such that shortest path between some pair of vertices in it is equal to dd . 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 kk . Can you help him and find any graph which satisfies PolandBall's requests?

输入格式

The only one input line contains two integers nn and kk ( 2<=n<=10002<=n<=1000 , 1<=k<=10001<=k<=1000 ), representing graph's size and sought colorfulness.

输出格式

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

Otherwise, you can output any graph which fulfills PolandBall's requirements. First, output mm — the number of red edges in your graph. Then, you should output mm lines, each containing two integers aia_{i} and bib_{i} , ( 1<=ai,bi<=n1<=a_{i},b_{i}<=n , aibia_{i}≠b_{i} ) which means that there is an undirected red edge between vertices aia_{i} and bib_{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.

输入输出样例

  • 输入#1

    4 1
    

    输出#1

    -1
    
  • 输入#2

    5 2
    

    输出#2

    4
    1 2
    2 3
    3 4
    4 5
    

说明/提示

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

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

首页