Logo
(追記) (追記ここまで)

19431번 - Hamiltonian $k$-vertex-connected Graph 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB132218.182%

문제

A graph (other than a complete graph) has connectivity $k$ if $k$ is the size of the smallest subset of vertices such that the graph becomes disconnected if you delete them.

A connected undirected graph $G$ is called Hamiltonian if it has a Hamiltonian cycle: a cycle that visits each vertex exactly once (except for the vertex that is both the start and the end, which is visited twice).

Bobo would like to construct a Hamiltonian graph with $n$ vertices which has connectivity $k$. Also, the number of edges in the graph should be minimum possible.

입력

The first line contains two integers $n$ and $k$ where $n$ is the number of vertices in the graph (3ドル \leq n \leq 100,ドル 1ドル \leq k \leq n - 2$).

출력

If there is no such graph, output $-1$ on a single line. Otherwise, output an integer $m$ denoting the minimum number of edges. Then in each of the next $m$ lines, output two integers $x$ and $y$ (1ドル \leq x, y \leq n,ドル $x \ne y$) denoting an edge in the graph. In the following line, output a permutation of integers 1,ドル 2, \ldots, n$ denoting a Hamiltonian cycle in the graph.

제한

예제 입력 1

4 2

예제 출력 1

4
1 2
2 3
3 4
4 1
1 2 3 4

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 9. Xi Lin Contest, Grand Prix of China J번

Contest > Open Cup > 2016/2017 Season > Stage 11: Grand Prix of China J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /