题目:https://www.luogu.org/problemnew/show/P2024 自己在做本题时最大的障碍就是:不会在一个集合的father改变时把相应的补集也跟着改变. 借鉴题解后,才明白原来就是把其补集也进行合并:由于fa数组在改变,不要定义一个变量为原来的find()在后面使用. 原来的乱七八糟代码: #include<iostream> #include<cstdio> using namespace std; int n,k,s; int fa[2000005…
P2978 [USACO10JAN]下午茶时间Tea Time 题目描述 N (1 <= N <= 1000) cows, conveniently numbered 1..N all attend a tea time every day. M (1 <= M <= 2,000) unique pairs of those cows have already met before the first tea time. Pair i of these cows who have…