加载中...

随笔分类 -  并查集

摘要:https://www.acwing.com/problem/content/description/1599/ #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace 阅读全文
posted @ 2022-08-22 23:41 英雄不问出处c 阅读(30) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1606/ #include <iostream> #include <algorithm> #include <vector> using namespace std; const int N = 10010; int 阅读全文
posted @ 2022-08-22 23:05 英雄不问出处c 阅读(29) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1487/ 并查集维护连通块的写法 #include <iostream> #include <cstring> using namespace std; const int N = 1010, M = 500010; i 阅读全文
posted @ 2022-08-22 22:59 英雄不问出处c 阅读(29) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1520/ 思路: 先找到在一个团伙中的人(可以用树的dfs来做,也可以用并查集来做),然后遍历每一个合法的集合,找到里面的头目。 并查集的做法 #include <iostream> #include <unordere 阅读全文
posted @ 2022-08-21 19:52 英雄不问出处c 阅读(27) 评论(0) 推荐(0)