
并查集
文章平均质量分 78
tian_he_he
GeeGee
展开
-
hpu暑假训练A - 畅通工程【并查集】
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每行给转载 2017-08-02 15:45:52 · 299 阅读 · 0 评论 -
hpu暑假训练D - 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原创 2017-08-02 15:56:52 · 266 阅读 · 0 评论