随笔分类 -  并查集

acm
摘要:#### 链接 https://www.luogu.com.cn/problem/P8686 #### 题意 给你 $n$ 个数 a[1...n],从 $a_2$ 开始,如果和之前的某个数具有相等的值,就一直让 $a_i = a_i + 1$,直到前面的任何一个数都和它不相等 $1 \leq n \ 阅读全文
posted @ 2023-05-29 15:34 starlightlmy 阅读(47) 评论(0) 推荐(0)
摘要://并查集模板 亲戚 #include<cstdio>using namespace std;int father[5005]; int f(int x){ //寻找每个结点的父亲结点 int r=x; while(father[r]!=r){ r=father[r]; } return r;} i 阅读全文
posted @ 2021-03-28 12:55 starlightlmy 阅读(49) 评论(0) 推荐(0)