SDUT 数据结构 欧拉回路
来源:互联网 发布:农村淘宝服务站利润表 编辑:程序博客网 时间:2024/05/16 07:21
无向图: 度数为偶数,且联通
#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>#define MAX 0x3f3f3fusing namespace std;int d[1100];int f[1100];int fd(int x){ return f[x] == x? x: f[x] = (fd(f[x]));}void check(int x, int y){ int xx = fd(x); int yy = fd(y); if(xx != yy) { f[xx] = yy; }}int main(){ int t; scanf("%d",&t); while(t--) { int n, m; scanf("%d%d",&n,&m); for(int i = 0; i <= n; i++) f[i] = i; while(m--) { int u, v; scanf("%d%d",&u,&v); d[u]++; d[v]++; check(u,v); } int flag = 0; for(int i = 1; i <= n; i++)///度数为偶数,无向图 { if(d[i]%2) { flag = 1; break; } } int cnt = 0; for(int i = 1; i <= n; i++)//联通 { if(f[i] == i) { cnt++; } } if(cnt != 1) { flag = 1; } if(!flag) { cout<<"1"<<endl; } else cout<<"0"<<endl; } return 0;}
0 0
- SDUT 数据结构 欧拉回路
- SDUT 3364 数据结构实验之图论八:欧拉回路
- SDUT OJ 3364 数据结构实验之图论八:欧拉回路
- SDUT-数据结构实验之图论八:欧拉回路
- SDUT 3364-欧拉回路
- SDUT 3364-数据结构实验之图论八:欧拉回路(并查集)
- 欧拉回路 + 数据结构 + dfs
- 数据结构与算法问题 欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- 数据结构实验之图论八:欧拉回路
- POJ 1528 Perfection
- online_judge_1016
- Eclipse搭建SSH(Struts2+Spring3+Hibernate3)框架项目教程及增删改查经验总结
- 1003.我要通过
- youzhu知识点2
- SDUT 数据结构 欧拉回路
- java实现DES加密和解密
- 狭义相对论
- C# 读写Word
- 监督学习和无,监督学习区别
- **原创**零基础学ios***OC课程02**数组NSArry
- POJ 1953 World Cup Noise (递推)
- 关于左移的双目运算符 求助一下大家
- Socket 通信原理