QOJ.ac

QOJ

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

#2369. 联合挖掘

الإحصائيات

鼹鼠一家最近决定挖掘一个新的隧道网络。网络布局已经确定,由若干个洞穴和连接它们的双向隧道组成,形成一个连通图。鼹鼠妈妈想借此机会教她的两个孩子如何挖掘隧道网络。

Mole by Ahmad Kanbar, Unsplash

作为初步的快速演示,鼹鼠妈妈打算先挖掘出几个洞穴和隧道,这些洞穴和隧道在规划的隧道网络中构成一条不自交的路径。然后,她会将剩余的洞穴分配给两个孩子,并确保每个孩子挖掘的洞穴数量相同,否则其中一个孩子会感到难过。(隧道挖掘起来容易得多,因此无需考虑。)孩子们可以以他们喜欢的任何顺序挖掘分配给他们的洞穴。

由于孩子们在挖掘隧道网络方面经验不足,鼹鼠妈妈意识到她的计划存在一个问题:如果两个孩子被分配的洞穴之间存在隧道,那么当另一个孩子恰好在连接的洞穴中挖掘时,挖掘该隧道可能会发生事故。

请帮助鼹鼠妈妈决定使用哪条路径进行初步演示,以及如何平均分配剩余的洞穴,使得没有任何隧道连接分配给不同孩子的洞穴。初始路径必须至少包含一个洞穴,且不能重复访问同一个洞穴。

输入格式

输入包含: 一行包含两个整数 $c$ 和 $t$ ($1 \le c \le 2 \cdot 10^5$, $0 \le t \le 2 \cdot 10^5$),分别表示规划隧道网络中的洞穴数量和隧道数量。 $t$ 行,每行包含两个整数 $a$ 和 $b$ ($1 \le a, b \le c, a \neq b$),描述洞穴 $a$ 和 $b$ 之间的一条双向隧道。

洞穴编号从 $1$ 到 $c$。任意两个洞穴之间最多只有一条隧道,且网络中任意两个洞穴之间都存在路径。

输出格式

首先输出两个整数 $p$ 和 $s$,分别表示鼹鼠妈妈初始演示路径上的洞穴数量,以及每个孩子需要挖掘的洞穴数量。然后输出一行,包含鼹鼠妈妈初始路径上的 $p$ 个洞穴,按她挖掘的顺序排列。接着输出两行,每行包含相应孩子需要挖掘的 $s$ 个洞穴,顺序不限。

输入保证至少存在一个有效解。如果存在多个有效解,你可以输出其中任意一个。

样例

输入格式 1

3 2
3 1
2 1

输出格式 1

3 0
3 1 2

输入格式 2

4 3
1 3
2 3
3 4

输出格式 2

2 1
3 4
2
1

输入格式 3

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

输出格式 3

3 2
5 2 7
6 1
3 4

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.