随笔分类 - 并查集
摘要:N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it i
阅读全文
摘要:A Bug's Life Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different gend
阅读全文
摘要:Navigation Nightmare Farmer John's pastoral neighborhood has N farms (2 <= N <= 40,000), usually numbered/labeled 1..N. A series of M (1 <= M < 40,000
阅读全文
摘要:Parity game Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a
阅读全文
摘要:Supermarket A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as a
阅读全文
摘要:True Liars After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he wa
阅读全文
摘要:How Many Answers Are Wrong TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the fol
阅读全文
摘要:传送门 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <queue> 5 #include <vector> 6 #include <cmath> 7 8 using namespace std
阅读全文
摘要:The Suspects 题目:编号为0的人有传染病,同组中只要有一个人有传染病,该组的人都被看做有传染病,一个人可以在多组中,问有多少人有传染病。 思路:并查集,需要压缩并查集的树,编号小的点优先作为祖先(0为root),并查集过程中传递祖先的同时传递祖先是否是病人,最后再次遍历所有人,使得祖先是
阅读全文
摘要:Wireless Network 思路:并查集,如果两个点可以相互传达,就是两个集合的合并,当然,前提是要两个点都被维修过。 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <queue> 5 #
阅读全文

浙公网安备 33010602011771号