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 question…
题目链接: K - Find them, Catch them POJ - 1703 题目大意:警方决定捣毁两大犯罪团伙:龙帮和蛇帮,显然一个帮派至少有一人.该城有N个罪犯,编号从1至N(N<=100000.将有M(M<=100000)次操作.D a b 表示a.b是不同帮派A a b 询问a.b关系. 具体思路:带权并查集模板题.一般并查集都是相同的放在一个联通块里面.对于这个题,我们可以利用一下这个性质,只要是有联系的,都放进一个连通块里面,然后我们查询的时候,如果说他们的祖先一样的话,就…
A Bug's Life POJ - 2492 Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gender. In his experiment, indi…
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31840 Accepted: 9807 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…