1960: 哈密尔顿环(Hamilton)
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:6
Solved:1
Description
哈密尔顿环是指不重复地走过所有的点,并且最后还能回到起点的回路。使用简单的深度优先搜索,就能求出一张图中所有的哈密尔顿环
Input
多行
第一行为n个顶点,m条边
后续为边的两个顶点
Output
多行
每个环为一行
Sample Input Copy
5 7
1 2
1 5
2 3
2 4
2 5
3 4
4 5
Sample Output Copy
1 2 3 4 5 1
1 2 4 5 1
1 2 5 1
2 3 4 2
2 3 4 5 2
2 4 5 2