QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#7321. 哈密顿 $k$-点连通图

الإحصائيات

一个图(非完全图)的连通度为 $k$,是指删除 $k$ 个顶点后图变得不连通,且 $k$ 是满足该条件的最小顶点子集大小。

一个连通无向图 $G$ 被称为哈密顿图,如果它包含一个哈密顿回路:即经过每个顶点恰好一次的回路(除了既是起点又是终点的顶点被访问两次外)。

Bobo 想要构造一个具有 $n$ 个顶点且连通度为 $k$ 的哈密顿图。此外,该图的边数应尽可能少。

输入格式

第一行包含两个整数 $n$ 和 $k$,其中 $n$ 是图中的顶点数($3 \le n \le 100$,$1 \le k \le n - 2$)。

输出格式

如果不存在这样的图,输出 $-1$。否则,输出一个整数 $m$,表示最少的边数。接下来的 $m$ 行,每行输出两个整数 $x$ 和 $y$($1 \le x, y \le n, x \neq y$),表示图中的一条边。在最后一行,输出一个 $1, 2, \dots, 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.