图论——并查集
来源:互联网 发布:gov域名注册 编辑:程序博客网 时间:2024/06/06 12:34
/*并查集模板by:mfcheer*/#include <iostream> #include <cstdio> #include <string> #include <cstring> #include <cstdlib> #include <algorithm> #include <vector> #include <set> #include <map> using namespace std;#define N 100010int n, m;int fa[N];int findd(int x){if (fa[x] == -1)return x;elsereturn fa[x] = findd(fa[x]);}void un(int x, int y){int fx = findd(x);int fy = findd(y);if (fx == fy)return;fa[fx] = fy;}int main(){memset(fa, -1, sizeof(fa));while (cin >> n >> m){un(n,m);}return 0;}
0 0
- 图论——并查集
- hdu1198—并查集
- 并查集—入门
- 并查集—应用
- 并查集—C
- sdnu-并查集&图论-weeklyexam ——C
- poj1611——并查集
- poj1988——并查集
- 数据结构——并查集
- 并查集——学习详解
- 并查集——HDOJ 1213
- 并查集——HDOJ 1272
- 并查集——HDOJ 1325
- 数据结构——并查集
- 数据结构——并查集
- hdu3726——treap,并查集
- POJ 1182 —— 并查集
- 并查集——畅通工程
- 堆排序(heapsort)
- 深度学习工具包(Deep Learning Toolboxs)
- Android适配器的用法
- Linux显示工作路径
- Visual Studio Warning C4996
- 图论——并查集
- 第十三章:13.4 系统定时任务
- Android控件用法
- OO的六大原则
- Linux显示一个二进制文件或可执行文件的完整路径
- android:Dialog点击其他区域消失
- Java线程:新特征-条件变量
- Android Fragment 基本介绍
- C#与C++函数调用