시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 11 | 2 | 2 | 18.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.
4 2
4 1 2 2 3 3 4 4 1 1 2 3 4