find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2524    Accepted Submission(s): 888 Problem Description Marica is very angry with Mirko because he found a new gi…
http://acm.hdu.edu.cn/showproblem.php?pid=1595 大致题意: 给一个图.让输出从中删除随意一条边后所得最短路径中最长的. . 思路: 直接枚举每条边想必是不行的.事实上有些边是不须要枚举的,由于删除它们并不影响起点到终点的最短路.起作用的边都是未删边前的最短路径上的边,删除它们最短距离肯定增大,仅仅需在这些最短距离中求最大的就可以. 记录最短路径上的边,仅仅需一个pre数组记录松弛时每一个点的前驱节点. #include <stdio.h> #inc…
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2702    Accepted Submission(s): 974 Problem Description Marica is very angry with Mirko because he found a new gi…
转载请注明出处:http://blog.csdn.net/a1dark 分析:经典的次短路问题.dijkstra或者SPFA都能做.先找出最短路.然后依次删掉没条边.为何正确就不证明了.了解思想直接A掉.注意记录路径 #include<stdio.h> #include<string.h> #define INF 0x7ffffff #define N 1010 int mpt[N][N]; int path[N]; int n,m; void init(){ for(int i=…
Problem Description Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn't live in the same city, she started preparing for the long journey.We know for every road how many minutes it takes to come f…
http://acm.hdu.edu.cn/showproblem.php?pid=1595 这道题我用spfa在枚举删除边的时候求最短路超时,改用dijkstra就过了. #include <cstdio> #include <queue> #include <cstring> #include <algorithm> #define maxn 1001 using namespace std; <<; int g[maxn][maxn]; i…
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 翻译: 找出字符串s中最长的回文子串,字符串s的最长是1000,假设存在唯一的最长回文子串 法一:直接暴力破解 O(N3)的时间复杂度,运行超…
题目描述: 在句子中找出最长的单词,并返回它的长度.函数的返回值应该是一个数字. 基本思路,将字符串转换成数组,然后得出数组中单个元素的长度,对长度进行排序,返回最大的一个 代码: function findLongestWord(str) { // 请把你的代码写在这里 var arr = []; str = str.split(" "); for(var i=0;i<str.length;i++){ arr.push(str[i].length); } arr.sort(fu…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1595 find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1665    Accepted Submission(s): 588 Problem Description Mari…
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1916    Accepted Submission(s): 668 Problem Description Marica is very angry with Mirko because he found a new g…