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…
题意:有两个犯罪集团,现在有两种操作,D [a] [b]表示a和b是属于不同犯罪集团的,A [a] [b] 是询问你a和b的关系,如果ab属于同一个犯罪集团,输出In the same gang. 如果ab属于不同犯罪集团,输出In different gangs. 否则输出 Not sure yet. 思路:赤裸裸的种类并查集,0代表ab属于同一集团,1代表不同,要是不在同个树里面,就是不确定....... #include<iostream> #include<cstd…
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 32225 Accepted: 9947 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 Drag…
做过一些的带权并查集,再来做所谓的"种类并查集",发现好像就顿悟了. 种类并查集与带权并查集实质上的区别并不大. 关键的区别就是种类并查集仅仅是带权并查集再弄个%取余操作而已.然后余数就表示他属于哪个种类. 这题仅仅有两个种类,也就是仅仅有0和1两种, 对于两个不同的种类,那么之间的权值是相差1的,所以依照带权并查集的方法做加上1.然后取余2就可以. #include<cstdio> const int N = 100005; int n, m, f[N], rank[N]…