我个人比较喜欢Kruskal算法,所以就把这个方法写了一下,但过不了洛谷,70分. 思路是先全读入,再排序,一条一条加边.运用并查集. #include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct s{ int h; int t; int w; }; ]; bool cmp(s a,s b) { return a.w < b.w; } int find(int…
Travel Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1852 Accepted Submission(s): 641 Problem Description Jack likes to travel around the world, but he doesn't like to wait. Now, he is t…
Highways description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a number of highways connecting som…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4750 题意:Q个询问t,求在一个无向图上有多少对点(i,j)满足 i 到 j 的所有路径上的最长边的最小值大于等于t. (i,j)所有路径上的最长边的最小值,容易想到就是 i, j之间的瓶颈路,瓶颈路也就是最小生成树上的边了.注意到每条边的权值都是不相等的,那么MST就是确定的.假设当前MST的边的权值是f[i],Kruskal的并查集中维护一个cnt[i],表示以节点 i 为根的集合的节点个数,那…
题目描述 You are given a weighed undirected connected graph, consisting of n vertices and mm edges. You should answer q queries, the i-th query is to find the shortest distance between vertices ui and vi. Input The first line contains two integers n and…
还是畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34391 Accepted Submission(s): 15542 Problem Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离.省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能…
畅通工程 Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 59 Accepted Submission(s) : 37 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通…
还是畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56352 Accepted Submission(s): 25580 Problem Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离.省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要…
Genghis Khan the Conqueror Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 327680/327680 K (Java/Others) Total Submission(s): 1687 Accepted Submission(s): 501 Problem Description Genghis Khan(成吉思汗)(1162-1227), also known by his birth name…
There 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 and only if there is a road between A and B, or there exists a…
You 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 points. For each possible route between two points,…