posted @ 2012-03-14 12:05
随笔分类 - 最小生成树
摘要:题目1012:畅通工程时间限制:1 秒内存限制:32 兆特殊判题:否提交:934解决:400题目描述: 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?输入: 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每行给出一对正整数,分别是该条道路直接连通的两个城镇的编号。为简单起见,城镇从1到N编号。 注意:两个城市之间可以有
阅读全文
摘要:http://poj.org/problem?id=2485由于本题是多CASE,全局变量忘记重置了,唉,WA了好多次!!!HighwaysTime Limit:1000MSMemory Limit:65536KDescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this pro
阅读全文
posted @ 2011-02-16 17:25
摘要:http://poj.org/problem?id=2421无向图的最小生成树 Kruskal算法Constructing RoadsTime Limit:2000MSMemory Limit:65536KDescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if
阅读全文
posted @ 2011-01-29 18:41
摘要:http://poj.org/problem?id=2560本题跟其他题差不多,只不过节点的权重需要自己计算FrecklesTime Limit:1000MSMemory Limit:65536KDescriptionIn an episode of the Dick Van Dyke show, little Richie connects the freckles on his Dad's back to form a picture of the Liberty Bell. Alas, one of the freckles turns out to be a scar, so
阅读全文
posted @ 2011-01-24 20:45
摘要:这题就是最小生成树,不过样例输出看了好久,一看DISCUSS才知道,这题是SPJ,答案不唯一,不必管样例下面Kruskal+并查集一次AC!!NetworkTime Limit:1000MSMemory Limit:30000KTotal Submissions:7721Accepted:2835Special JudgeDescriptionAndrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in th
阅读全文
posted @ 2010-12-18 08:59
摘要:这题的题意并不难,就是根据不同车型的代号分别求出两个代号的“距离”然后根据距离选择一个最小的生成树,下面用Kruskal算法实现,虽然AC了,资源占用很大,还需改进Truck HistoryTime Limit:2000MSMemory Limit:65536KDescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has
阅读全文
posted @ 2010-12-17 14:50
摘要:POJ 1287NetworkingTime Limit:1000MSMemory Limit:10000KTotal Submissions:2924Accepted:1579DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may connect pairs of p
阅读全文
posted @ 2010-11-15 14:06
浙公网安备 33010602011771号