1 Star 0 Fork 0

hsmath/PAT advanced

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
1126.cpp 1015 Bytes
一键复制 编辑 原始数据 按行查看 历史
hsmath 提交于 2021-07-18 00:39 . New Start
/**
* @file 1126.cpp
* @author Shuang Hu <hsmath@ubuntu>
* @date Thu Jun 3 03:37:50 2021
*
* @brief PAT 1126:Judge a graph have Eulerian Path or not.
*
*
*/
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;
int main(){
bool ifconnected=true;
int nodenum;
int edgenum;
cin>>nodenum>>edgenum;
map<int,int> degrees;
vector<bool> traversed;
int odddegree=0;
for(int i=0;i<edgenum;i++){
int a,b;
cin>>a>>b;
degrees[a]++;
degrees[b]++;
}
cout<<degrees[1];
if(degrees[1]%2){
odddegree++;
}
for(int i=2;i<=nodenum;i++){
cout<<" "<<degrees[i];
if(degrees[i]%2){
odddegree++;
}
}
cout<<endl;
traversed.resize(nodenum);
queue<int> Que;
Que.push(0);
while(Que.empty()==false){
int d=Que.front();
Que.pop();
}
if(odddegree==0){
cout<<"Eulerian"<<endl;
}else if(odddegree==2){
cout<<"Semi-Eulerian"<<endl;
}else{
cout<<"Non-Eulerian"<<endl;
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hsmath/pat-advanced.git
git@gitee.com:hsmath/pat-advanced.git
hsmath
pat-advanced
PAT advanced
master

搜索帮助