随笔分类 - 并查集&最小生成树
摘要:题目:链接 Problem Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two d
阅读全文
摘要:题目:链接 Problem Description In China, foreign brand commodities are often much more expensive than abroad. The main reason is that we Chinese people ten
阅读全文
摘要:题目链接 代码: 总结: 刚开始还以为只是ans[qq[i].index] = num[j] * (num[j] - 1),结果WA,后来才发现这样计算虽然案例都符合但是是错的,如果案例过了,还WA,还真得考虑下是计算方面引起的错误。
阅读全文
摘要:题目: Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X
阅读全文
摘要:题目: Problem Description 老 Jack 有一片农田,以往几年都是靠天吃饭的。但是今年老天格外的不开眼,大旱。所以老 Jack 决定用管道将他的所有相邻的农田全部都串联起来,这样他就可以从远处引水过来进行灌溉了。当老 Jack 买完所有铺设在每块农田内部的管道的时候,老 Jack
阅读全文
摘要:题目: Problem Description There are N (2<=N<=600) cities,each has a value of happiness,we consider two cities A and B whose value of happiness are VA an
阅读全文
摘要:题目: Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he need
阅读全文
摘要:题目: Problem Description Mr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it w
阅读全文
摘要:题目: Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villag
阅读全文
摘要:题目: Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect
阅读全文
摘要:题目: Problem Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可
阅读全文
摘要:题目: Problem Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input
阅读全文
摘要:题目: Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包
阅读全文