Sample Input 1:
7 12
5 7
1 2
1 3
2 3
2 4
3 4
5 2
7 6
6 3
4 5
6 4
5 6
Sample Output 1:
2 4 4 4 4 4 2
Eulerian
Sample Input 2:
6 10
1 2
1 3
2 3
2 4
3 4
5 2
6 3
4 5
6 4
5 6
Sample Output 2:
2 4 4 4 3 3
Semi-Eulerian
Sample Input 3:
5 8
1 2
2 5
5 4
4 1
1 3
3 2
3 4
5 3
Sample Output 3:
3 3 4 3 3
Non-Eulerian
题解:
直接用邻接表存储图结构,
同时用一个degree[]
数组存储每个节点的度,
用dfs
方式遍历图,判断其是否连通(注:无法用degree[i]==0
判断,测试点3过不去),
如果图不连通,则该图不是欧拉回路,
#include <iostream>
#include <vector>
using namespace std;
int n,m;
int degree[510];
int odd_cnt