QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#18585. DIMIGO 控制

Estadísticas

西元 $2039$ 年,Dimigo 有 $N$ 座編號從 $1$ 到 $N$ 的建築物,以及 $M$ 條連接這些建築物的道路。任意兩座建築物之間至多只有一條直接相連的道路。

某天學校爆發了病毒,全校學生面臨感染危機。為了阻止病毒傳播,你決定進行 $0$ 次或多次以下控制作業,以封鎖所有道路:

  • 選擇一座與尚未被封鎖的道路直接相連的建築物,封鎖該建築物所有直接相連的道路。

為了學生的安全,你決定盡可能多次地進行控制作業。請找出進行控制作業的順序。

輸入格式

第一行包含兩個整數 $N$ 和 $M$,分別代表建築物的數量與道路的數量,兩者以空白分隔。$(1 \le N \le 10^{5}; 0 \le M \le 10^{5})$

接下來 $M$ 行,每行包含兩個整數 $u$ 和 $v$,代表該道路連接的兩座建築物編號,以空白分隔。$(1 \le u, v \le N; u \ne v)$

輸出格式

第一行輸出可以進行控制作業的最大次數 $K$。

接下來 $K$ 行,每行依序輸出進行控制作業的建築物編號。

若存在多種使控制作業次數最大化的方法,輸出其中任意一種即可。

範例

範例輸入 1

3 3
3 2
3 1
2 1

範例輸出 1

2
2
3

範例輸入 2

10 8
4 10
10 7
1 4
8 6
10 1
1 9
7 4
9 5

範例輸出 2

6
7
10
4
5
9
8

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.