Sample Input 1 //T 3 //n0 990 692 //邻接矩阵990 0 179692 179 0Sample Output 692 prim # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # define LL long long using namespace std ;…
Description The 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 problem. They're planning to build some highways so that i…
Out of Hay Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18472   Accepted: 7318 Description The cows have run out of hay, a horrible event that must be remedied immediately. Bessie intends to visit the other farms to survey their hay s…
题目链接:https://vjudge.net/problem/POJ-2349 题意: 题目就是要我们找到一个最小的值D,把图里面所有大于D的边去掉之后剩余的连通分支的数量为S.这个就是找这个图里面最小生成树的第S大的边(也就是第n-S小的边),我们可以依照求最小生成树的过程来,首先对于每一个单点,我们把它看成一个点集,这样一开始我们有n个点集,然后我们找一条距离最小的边,合并边连接的两个点集,这样集合总数就变成了n-1个,假设我们要找一个最小的D,去掉大于D的边,使得连通分支数位n-1,那么…
题目大意: 有一些炮台,如果这个炮台有卫星接收器,那么任意两个有卫星接收器的炮台可以通信,不受距离限制:否者,两个炮台之间只能通过对讲机通信,这是受距离限制的.要买一种对讲机,用在需要的炮台上,要求所有炮台两两之间可以直接或者间接通信,问要买通信距离D至少为多少的对讲机可以满足要求. 有S个卫星接收器,那么就可以减少S-1个距离开销.要让D尽可能小,就让这S-1个距离开销最大,所以,想法就是,求这些点的最小生成树,然后把所选的边排序,第S大的边的权值就是所求.假如有4个点,2个卫星,那么最长的那…
POJ2395 Out of Hay 寻找最小生成树中最大的边权. 使用 Kruskal 求解,即求选取的第 \(n-1\) 条合法边. 时间复杂度为 \(O(e\log e)\) . #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int maxn = 10005; int n, m, tot, f[2005]; struct edge{ int f…
点击打开链接 Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19004   Accepted: 8815 Description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia.…
题目 给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 的最大长度为 1000. 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案. 示例 2: 输入: "cbbd" 输出: "bb" 来源:力扣(LeetCode) 人生苦短,我用python!简单的思路最适合大多数人! python的精髓在于简单,灵活,用少的代码完成别的语言相同的工作! 最长回文…
                                                                                                                Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23426   Accepted: 10829 Description The island nation of Flatopia is…
Description The 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 problem. They're planning to build some highways so that i…