QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#12866. 库拉托夫斯基

统计

Kuratowski-Pontryagin 定理是平面图的一种禁止子图刻画。它指出,一个有限图是平面图的充要条件是它不包含 $K_5$(五顶点的完全图)或 $K_{3,3}$(六顶点的完全二分图,其中一部分的三个顶点分别与另一部分的三个顶点相连)的细分作为子图。

小 Max 想要检查他最喜欢的图是否是平面图。他只是个小学生,不知道“细分”这个词,所以他至少想在图中找到一个完全等同于 $K_5$ 或 $K_{3,3}$ 的子图。帮帮他!请找出 $K_5$ 或 $K_{3,3}$,或者报告它们不存在。

图的子图是其顶点和边的一个子集,其中每条被选中的边的两个端点都在被选中的顶点子集中。与导出子图不同,可以选取边的任意子集,而不必包含所选顶点之间的所有边。例如,$K_{3,3}$ 是 $K_6$ 的一个子图。

输入格式

输入的第一行包含两个空格分隔的整数 $n$ 和 $m$:图的顶点数和边数($1 \le n \le 400$,$0 \le m \le \frac{n(n-1)}{2}$)。接下来的 $m$ 行,每行包含两个 $1$ 到 $n$ 之间的整数,表示图的一条边。图中不存在重边和自环。

输出格式

如果给定的图中既不包含 $K_5$ 子图,也不包含 $K_{3,3}$ 子图,请输出单词 “NO”。

如果找到了 $K_5$ 子图,请在第一行输出 “K5”,并在第二行输出五个整数:构成该子图的顶点编号。

如果找到了 $K_{3,3}$ 子图,请在第一行输出 “K33”,并在接下来的两行中各输出三个整数:分别表示子图中两个部分的顶点编号。

如果存在多个该类型的子图,输出其中任意一个即可。

样例

输入 1

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

输出 1

K33
1 2 3
4 5 6

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.