无向图欧拉路的判定
来源:互联网 发布:知彼客服 编辑:程序博客网 时间:2024/06/05 16:28
#include<cstdio>//图联通 并且有2个或者没有奇数度节点,没有的是欧拉回路#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn=1e6+10;int bin[maxn];int finds(int x){ int flag=x,j; while(x!=bin[x]) x=bin[x]; while(bin[flag]!=x) { j=flag; flag=bin[flag]; bin[j]=x; } return x;}void merger(int a,int b){ bin[finds(a)]=bin[finds(b)];}int x[maxn];int main(){ int n,m; while(~scanf("%d%d",&n,&m)) { memset(x,0,sizeof(x)); for(int i=0; i<m; i++) { int a,b; scanf("%d%d",&a,&b); x[a]++; x[b]++; merger(a,b); } int flag=0; for(int i=2; i<=n; i++)//用并查集判读图的联通性 if(finds[1]!=finds[i]) { flag=1; break; } int ans=0; for(int i=1; i<=n; i++)//判断结点的度数 if(x[i]%2) ans++; if(ans==0||ans==2||flag==0)//存在欧拉路 printf("Full\n"); else printf("Part\n"); }}
0 0
- 无向图欧拉路的判定
- 无向图欧拉回路的判定
- 无向图欧拉回路的判定之hdu1878
- poj 2513 Colored Sticks,无向欧拉图的判定,Trie,hash
- poj 2793 Cactus(无向仙人掌图判定)
- HDU 5215 Cycle(判定无向图奇偶环)
- eoj 1816. 连通(无向图是否连通判定)
- poj 2942 Knights of the Round Table(无向图的双连通分量+二分图判定)
- poj1041 John's trip【无向图欧拉回路判定+输出路径】
- poj2942 Knights of the Round Table,无向图点双联通,二分图判定
- 【欧拉回路(无向图判定)】hdu 1878 欧拉回路
- HDOJ 1878 欧拉回路(判定无向图欧拉回路简单题)
- ZOJ-3732 Graph Reconstruction(判定无向图度数序列能否可图化)
- 无向图的连通性
- 无向回路的求法
- 无向图求点割集的算法
- 无向图的实现
- 无向图的实现
- servlet执行流程
- centos + python + uwsgi 搭建网站
- Struts2-上传/下载文件功能实现
- memcache的搜索次数,每页数据存在memcache中,分页普通页面
- 树莓派搭建web系列
- 无向图欧拉路的判定
- html5 输入某范围求水仙花数
- android中EditText监听键盘输入
- Hiho 121 后缀数组二·重复旋律2(最长不可重叠重复子串问题)
- 161023
- KThread
- python之selenium模拟登录QQ空间
- 构建者模式——Builder模式
- 【Domoticz】玩转Domoticz平台——配合ESPEasy固件,开个头,以后玩起来起来再更新博客