poj(1703) Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26992   Accepted: 8188 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, G…
题目: The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which gang a criminal belongs to. The present questio…
题目:Find them,Catch them 刚开始以为是最基本的并查集,无限超时. 这个特殊之处,就是可能有多个集合. 比如输入D 1 2  D 3 4 D 5 6...这就至少有3个集合了.并且任意2个集合之间成员的敌我关系不明. 这里每个集合里面的成员关系要记录,他们在一个集合里,只是因为他们关系明确,敌人或者朋友. 千万不要简单的认为成朋友在一个集合,敌人在另外一个集合,分成2个集合.因为题目说只有2个匪帮,很容易进入这个误区. 我们只要记录一个成员和自己父亲的敌我关系和建树就可以了.…
Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 32073   Accepted: 9890 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon…
                                         Find them, Catch them 好久没有做并查集的题,竟然快把并查集忘完了. 题意:大致是有两个监狱,n个犯人,m次操作,每次操作可以是查询也可以是确定两个人是否在同一个监狱里. 思路:其实这题完全可能做出来,结果就是没做出来.理清思路还是很好想的,我们用一个并查集来把能够确定在同一监狱里的人放在一个集合里,用一个diff数组把确定不同监狱的两个犯人分别与对方不同监狱的犯人放在一个集合里,就是这么简单.…
POJ 2236 Wireless Network http://poj.org/problem?id=2236 题目大意: 给你N台损坏的电脑坐标,这些电脑只能与不超过距离d的电脑通信,但如果x和y均能C通信,则x和y可以通信.现在给出若干个操作, O p 代表修复编号为p的电脑 S p q代表询问p和q是不是能通信. 思路: 并查集即可.. 如果修复了一台电脑,则把与它相连距离不超过d的且修复了的放在一个集合里面. #include<cstdio> #include<cstring&…
题意:城市中有两个帮派,输入中有情报和询问.情报会告知哪两个人是对立帮派中的人.询问会问具体某两个人的关系. 思路:并查集的应用.首先,将每一个情报中的两人加入并查集,在询问时先判断一下两人是否在一个集合中,如果是,则表明两个人的关系已知. 本题还需要判断出两人是不是在同一帮派,这里用一个relation数组来维护每个人与根结点的关系. 0表示该人与根节点为同一个帮派. 1表示该人与根节点为对立帮派. 并查集有两个基本操作:find——查找根节点, merge——合并两个集合. 在合并两个集合时…
Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42451   Accepted: 13059 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Drago…
Find them, Catch them Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1703 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs…
手动博客搬家:本文发表于20170805 21:25:49, 原地址https://blog.csdn.net/suncongbo/article/details/76735893 URL: http://poj.org/problem?id=1703 题目大意:本题即很经典的"龙帮虎帮"问题. 有n个元素(n<=1e5),分布在两个不同的集合里. 现在有M个语句(m<=1e5),每个语句共两种:(1) 给定某两个元素在不同的集合中.(2) 询问两个元素是否在同一集合中.对…