![](https://img-blog.csdnimg.cn/20190918140158853.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
并查集
文章平均质量分 87
并查集
_sky123_
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #738 (Div. 2) D2. Mocha and Diana (Hard Version)
题目链接This is the hard version of the problem. The only difference between the two versions is the constraint on nnn. You can make hacks only if all versions of the problem are solved.A forest is an undirected graph without cycles (not necessarily connecte原创 2021-08-16 22:21:05 · 282 阅读 · 0 评论 -
Harbour.Space Scholarship Contest 2021-2022 G. Common Divisor Graph
题目链接Consider a sequence of distinct integers a1,…,ana_1, \ldots, a_na1,…,an, each representing one node of a graph. There is an edge between two nodes if the two values are not coprime, i. e. they have a common divisor greater than 111.There are qqq qu原创 2021-07-26 23:45:45 · 112 阅读 · 0 评论 -
P3402 可持久化并查集
题目链接题目描述给定 nnn 个集合,第 iii 个集合内初始状态下只有一个数,为 iii 。有 mmm 次操作。操作分为 333 种:1 a b 合并 a,ba,ba,b 所在集合;2 k 回到第 kkk 次操作(执行三种操作中的任意一种都记为一次操作)之后的状态;3 a b 询问 a,ba,ba,b 是否属于同一集合,如果是则输出 111 ,否则输出 000 。输入格式第一行两个整数,n,mn,mn,m 。接下来 mmm 行,每行先输入一个数 optoptopt 。若 opt=2opt原创 2021-05-02 21:02:25 · 119 阅读 · 0 评论 -
Educational Codeforces Round 82 (Rated for Div. 2) F. Number of Components
题目链接You are given a matrix n×mn \times mn×m, initially filled with zeroes. We define ai,ja_{i, j}ai,j as the element in the iii-th row and the jjj-th column of the matrix.Two cells of the matrix are connected if they share a side, and the elements in th原创 2021-02-27 17:08:48 · 156 阅读 · 0 评论 -
Codeforces Round #681 (Div. 1) B. Identify the Operations
题目链接We start with a permutation a1,a2,…,ana_1,a_2,…,a_na1,a2,…,an and with an empty array bbb. We apply the following operation kkk times.On the iii-th iteration, we select an index tit_iti (1≤ti≤n−i+1)(1≤t_i≤n−i+1)(1≤ti≤n−i+1), remove ati from the原创 2020-11-05 21:10:20 · 197 阅读 · 0 评论 -
P2542 [AHOI2005] 航线规划
题目链接对 Samuel 星球的探险已经取得了非常巨大的成就,于是科学家们将目光投向了 Samuel 星球所在的星系——一个巨大的由千百万星球构成的 Samuel 星系。星际空间站的 Samuel II 巨型计算机经过长期探测,已经锁定了 Samuel 星系中 nnn 个星球的空间坐标,并对这些星球以 111 至 nnn 依次编号。一些先遣飞船已经出发,在星球之间开辟探险航线。探险航线是双向的,例如从 111 号星球到 333 号星球开辟探险航线,那么从 333 号星球到 111 号星球也可以使用这原创 2020-10-14 20:30:29 · 292 阅读 · 0 评论 -
2020 Multi-University Training Contest 2 Total Eclipse
题目链接Problem DescriptionThere are nnn cities and m bidirectional roads in Byteland. These cities are labeled by 1,2,…,n1,2,…,n1,2,…,n, the brightness of the iii-th city is bib_ibi.Magician Sunset wants to play a joke on Byteland by making a total eclips原创 2020-08-28 15:05:42 · 174 阅读 · 0 评论 -
Columns Swaps
You are given a table a of size 2×n2×n2×n (i.e. two rows and n columns) consisting of integers from 111 to nnn.In one move, you can choose some column jjj (1≤j≤n)(1≤j≤n)(1≤j≤n) and swap values a1,ja_{1,j}a1,j and a2,ja_{2,j}a2,j in it. Each column can b原创 2020-08-11 23:54:01 · 751 阅读 · 0 评论 -
Operating on a Graph
链接:https://ac.nowcoder.com/acm/contest/5668/G来源:牛客网题目描述You are given a graph containing nnn vertices and mmm edges. Vertices are numbered from 000 to n−1n-1n−1. Initially, vertex iii belongs to group iii. We define a group AAA is connected to group BBB原创 2020-07-31 17:03:29 · 209 阅读 · 0 评论 -
Merging Towers
You have a set of nnn discs, the iii-th disc has radius iii. Initially, these discs are split among mmm towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order of their radii from bottom to top.You would l原创 2020-07-26 10:54:35 · 186 阅读 · 0 评论