QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#7321. ハミルトン $k$ 頂点連結グラフ

統計

グラフ(完全グラフを除く)について、頂点を取り除くとグラフが非連結になるような頂点の部分集合の最小の大きさが $k$ であるとき、そのグラフの連結度は $k$ であるといいます。

連結な無向グラフ $G$ がハミルトン閉路を持つとき、$G$ はハミルトングラフと呼ばれます。ハミルトン閉路とは、各頂点をちょうど 1 回ずつ訪れる閉路です(ただし、始点と終点を兼ねる頂点は 2 回訪れます)。

Bobo は、頂点数が $n$、連結度が $k$ のハミルトングラフを構成したいと考えています。また、そのグラフの辺の数を可能な限り少なくしたいと考えています。

入力

最初の行には 2 つの整数 $n,k$ が与えられます。$n$ はグラフの頂点数です($3 \le n \le 100$、$1 \le k \le n-2$)。

出力

そのようなグラフが存在しない場合は、1 行に $-1$ を出力してください。存在する場合は、辺の本数の最小値を表す整数 $m$ を出力してください。続く $m$ 行にはそれぞれ、グラフの辺を表す 2 つの整数 $x,y$($1 \le x,y \le n$、$x \ne y$)を出力してください。その次の行には、グラフのハミルトン閉路を表す、整数 $1,2,\ldots,n$ の順列を出力してください。

入出力例

入力 1

4 2

出力 1

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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.