poj 1703 罪犯的帮派

本文介绍了如何使用并查集解决POJ 1703题目的罪犯帮派问题。通过opp数组清晰表示不同帮派的编号,提供了一种思路明确的解决方案。
摘要由CSDN通过智能技术生成

并查集基础题目

http://blog.sina.com.cn/s/blog_6635898a0100kco0.html

这里用opp数组表示不在一个帮派的编号(2值)感觉思路比较清晰

#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
using namespace std;

///宏定义
const int INF = 20000000;
const int MAXN = 100050;
///全局变量 和 函数
int father[MAXN];
int opp[MAXN];
int find_set(int x)
{
	if (x != father[x])
		father[x] = find_set(father[x]);
	return father[x];
}
void
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值