-
Notifications
You must be signed in to change notification settings - Fork 2
/
1126.cpp
41 lines (37 loc) · 922 Bytes
/
1126.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <vector>
using namespace std;
const int N = 505;
vector<int> graph[N];
bool mark[N];
void dfs(int v) {
mark[v] = true;
for (auto w : graph[v])
if (!mark[w]) dfs(w);
}
bool is_connected(int n) {
dfs(1);
for (int v = 1; v <= n; v++)
if (!mark[v]) return false;
return true;
}
int main() {
int n, m;
cin >> n >> m;
while (m--) {
int v, w;
cin >> v >> w;
graph[v].push_back(w);
graph[w].push_back(v);
}
int count = 0;
for (int v = 1; v <= n; v++) {
count += graph[v].size() & 1;
cout << graph[v].size() << (v < n ? ' ' : '\n');
}
if (!is_connected(n)) cout << "Non-Eulerian" << endl;
else if (count == 0) cout << "Eulerian" << endl;
else if (count == 2) cout << "Semi-Eulerian" << endl;
else cout << "Non-Eulerian" << endl;
return 0;
}