题意:       让你求一颗生成树,使得最长边和最短边长度差值最小. 思路:      额!!!感觉这个思路会超时,但是ac了,暂时没什么别的好思路,那么就先说下这个思路,大牛要是有好的思路希望能在下面留言,相互学习,我的方法是先把所有的边都按长度排序,然后枚举没一颗生成树,这样枚举能得到正确答案的原因是,如果是求最小的差值,那么最终的答案一定是在sort之后的连续的以段,我们只要枚举每一段就行了,但是这样的时间复杂度是O(M^2)的,如果碰到奇葩数据估计一组可能跑到将近1s这样就T了,呵呵.…
Slim Span Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7102   Accepted: 3761 Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G is an ordered pair (V, E), where V …
题目链接:http://poj.org/problem?id=3522 Slim Span Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7522   Accepted: 3988 Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G…
Slim Span Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=3522 Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G is an ordered pair (V, E), where V is a se…
http://poj.org/problem?id=3522 Slim Span Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5666   Accepted: 2965 Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G is a…
题目链接:http://poj.org/problem?id=3522思路:题目要求最小生成树中最大边与最小边的最小差值,由于数据不是很大,我们可以枚举最小生成树的最小边,然后kruskal求最小生成树,直到不能生成生成树为止,然后取最小的差值即可. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define MA…
http://poj.org/problem?id=2774 我想看看这里的后缀数组:http://blog.csdn.net/u011026968/article/details/22801015 本文主要讲下怎么hash去找 開始的时候写的是O(n^2 logn)算法 果断超时. ..尽管也用了二分的.. 代码例如以下: //hash+二分 #include <cstdio> #include <cstring> #include <algorithm> #incl…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 25752   Accepted: 10483 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days…
POJ 1458 最长公共子序列 题目大意:给出两个字符串,求出这样的一 个最长的公共子序列的长度:子序列 中的每个字符都能在两个原串中找到, 而且每个字符的先后顺序和原串中的 先后顺序一致. Sample Input : abcfbc abfcab programming contest abcd mnp Sample Output 4 2 0 分析: 输入两个串s1,s2, 设dp(i,j)表示: s1的左边i个字符形成的子串,与s2左边的j个 字符形成的子串的最长公共子序列的长度(i,j从…
题目链接:http://poj.org/problem?id=3522 Time Limit: 5000MS Memory Limit: 65536K Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G is an ordered pair (V, E), where V is a set of verti…