1126. Eulerian Path (25)

简介: #include #include #include using namespace std;vector v;vector visit;int cnt = 0;//cnt != n判断不是连通图void df...
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int>> v;
vector<bool> visit;
int cnt = 0;//cnt != n判断不是连通图
void dfs(int index){
    visit[index] = true;
    cnt++;
    for (int i = 0; i < v[index].size(); i++) {
        if(visit[v[index][i]] == false){
            dfs(v[index][i]);
        }
    }
}
int main(){
    int n, m, a, b, even = 0;
    cin >> n >> m;
    v.resize(n + 1);
    visit.resize(n + 1);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        if(i != 1) cout << " ";
        cout << v[i].size();
        if(v[i].size() % 2 == 0) even++;
    }
    cout << endl;
    dfs(1);
    if(even == n && cnt == n) cout << "Eulerian\n";
    else if(even == n - 2 && cnt == n) cout << "Semi-Eulerian\n";
    else cout << "Non-Eulerian\n";
    return 0;
}







目录
相关文章
|
5月前
|
机器学习/深度学习 监控 数据可视化
Ultralytics是什么?
【8月更文挑战第3天】Ultralytics是什么?
299 0
|
7月前
|
计算机视觉
detectMultiScale
【6月更文挑战第8天】
340 4
|
开发工具 Python
ignatureNonceIsNull
ignatureNonceIsNull
78 1
我应该使用 NULL 还是 0?
我应该使用 NULL 还是 0?
|
人工智能
Colorful Slimes
题目描述 Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.
100 0
|
JavaScript 前端开发