QOJ.ac

QOJ

Time Limit: 2.5 s Memory Limit: 2048 MB Total points: 100

#15789. Two Sets

الإحصائيات

给定一个包含 $N$ 个顶点和 $M$ 条边的无向图,顶点编号从 $1$ 到 $N$。

你需要选择两个整数 $p$ 和 $q$,使得:

  • $N < (p + 1)(q + 1)$
  • 存在一个非空顶点集合 $S_1$,使得对于 $S_1$ 中的每一个顶点 $u$,在 $S_1$ 中至少有 $p$ 个与 $u$ 相连的顶点。
  • 存在一个大小至少为 $q$ 的顶点集合 $S_2$,使得对于 $S_2$ 中的每一个顶点 $u$,在 $S_2$ 中没有与 $u$ 相连的顶点。

你需要找到 $p$、$q$,以及满足上述要求的任意 $S_1$ 和 $S_2$。可以证明这样的 $p$ 和 $q$ 总是存在的。

输入格式

第一行包含两个整数 $N$ 和 $M$ ($1 \le N \le 2000; 0 \le M \le \min(\frac{N(N-1)}{2}, 200\,000)$)。接下来的 $M$ 行,每行包含两个整数 $u$ 和 $v$ ($1 \le u < v \le N$),表示连接这两个顶点的边。所有给定的边均不相同。

输出格式

第一行包含两个整数 $p$ 和 $q$。第二行包含一个整数 $|S_1|$,随后是 $|S_1|$ 个整数,表示 $S_1$ 中的顶点编号。第三行包含一个整数 $|S_2|$,随后是 $|S_2|$ 个整数,表示 $S_2$ 中的顶点编号。

样例

输入 1

4 2
1 2
3 4

输出 1

1 2
2 1 2
2 3 1

说明 1

你选择了 $p = 1, q = 2, S_1 = \{1, 2\}$ 以及 $S_2 = \{1, 3\}$。

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.