#P6743. [BalticOI 2014] Senior Postmen (Day2)

    ID: 5723 远端评测题 5000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索2014Special Judge深度优先搜索,DFSBalticOI

[BalticOI 2014] Senior Postmen (Day2)

Description

Given a connected undirected graph with NN vertices and MM edges, find several simple cycles such that:

  • These cycles do not share any edges.
  • These cycles cover all vertices and edges.

A simple cycle is a cycle that does not pass through any vertex more than once.

It is guaranteed that the graph has no multiple edges, and that a solution exists.

Input Format

The first line contains two integers N,MN, M, representing the number of vertices and the number of edges.
The next MM lines each contain two integers u,vu, v, representing an edge.

Output Format

Output several lines. Each line contains several integers representing one simple cycle.

10 15
1 3
5 1
2 3
9 2
3 4
6 3
4 5
7 4
4 8
5 7
8 5
6 7
7 8
8 10
10 9
2 3 4 5 8 10 9
7 8 4
1 5 7 6 3

Hint

Sample Explanation

For Sample 11:

Constraints

This problem uses bundled tests.

  • Subtask 1 (38 pts): N2000N \le 2000, M105M \le 10^5.
  • Subtask 2 (17 pts): N,M105N, M \le 10^5.
  • Subtask 3 (45 pts): No special constraints.

For 100%100\% of the testdata, 3N,M5×1053 \le N, M \le 5 \times 10^5.

This problem uses Special Judge.

Thanks to the SPJ provider

https://www.luogu.com.cn/user/60864

Notes

Translated from BalticOI 2014 Day2 C Senior Postmen

Translated by ChatGPT 5