QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#492. 嵌入毛毛虫

الإحصائيات

$n$ 阶毛毛虫图是一个具有 $2n$ 个顶点的图,其结构如下:一条长度为 $n$ 的路径,且每个内部顶点都连接着另一个顶点。下图展示了阶数为 3、4 和 5 的毛毛虫图。

图 $G$ 到图 $H$ 的嵌入是一个映射 $\varphi: VG \to VH$,将 $G$ 的顶点映射到 $H$ 的顶点,使得 $\varphi$ 是单射,且如果 $uv$ 是 $G$ 中的一条边,则 $\varphi(u)\varphi(v)$ 是 $H$ 中的一条边。

多个图 $G_1, G_2, \dots, G_k$ 到 $H$ 的同时嵌入是一组嵌入 $\varphi_1, \varphi_2, \dots, \varphi_k$,使得对于 $H$ 中的每一条边 $uv$,至多存在一个 $i$ 使得存在 $G_i$ 中的边 $xy$ 满足 $uv = \varphi_i(x)\varphi_i(y)$。

下图展示了三个 3 阶毛毛虫图到完全图 $K_6$ 的同时嵌入。你需要推广这种构造,并实现三个 $n$ 阶毛毛虫图到 $K_{2n}$ 的同时嵌入。

输入格式

输入文件包含多组测试数据。每组测试数据由一行中的单个整数 $n$ 组成($3 \le n \le 100$)。最后一行测试数据以 $n = 0$ 结尾,该行不应被处理。每个输入文件中最多有 10 组测试数据。

输出格式

对于每组测试数据,输出三行。设每个毛毛虫图的顶点编号为 $1$ 到 $2n$,排列方式如下:顶点 $1$ 到 $n+1$ 沿路径排列,顶点 $n+2$ 连接到顶点 $2$,顶点 $n+3$ 连接到顶点 $3$,以此类推。对于每个毛毛虫图,输出所有 $u \in \{1, \dots, 2n\}$ 的 $\varphi_i(u)$。

样例

样例输入 1

3
0

样例输出 1

1 2 3 4 5 6
1 4 5 3 2 6
2 6 1 3 4 5

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.