并查集
ZCY19990813
不断丰富自己,变得有底气!
展开
-
并查集N(The Suspects)
Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is t...原创 2018-05-24 20:41:53 · 195 阅读 · 0 评论 -
(并查集)Ubiquitous Religions
There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university b...原创 2018-05-21 20:15:15 · 140 阅读 · 0 评论 -
(并查集)How Many Tables
Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, a...原创 2018-05-21 19:52:21 · 192 阅读 · 0 评论 -
并查集
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,...原创 2018-05-21 19:42:53 · 223 阅读 · 0 评论 -
News Distribution(Codeforces 1167C)并查集
Input 7 5 3 2 5 4 0 2 1 2 1 1 2 6 7 Output 4 4 1 4 4 2 2 题意:n(人数),m(组数),m行,先输入k,表示这组有k个人,下面是k个人的编号,同组可以传递信息,问当第i个人是信息源时,有几个人知道信息。 思路:并查集,最好用递归的findd函数,先求出F数组(祖先的编号),然后看第i有几个编号相同的。 AC代码: #includ...原创 2019-07-28 09:27:37 · 222 阅读 · 0 评论