E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
shortest
Double
Shortest
Paths 网络流
Double
Shortest
Paths Alice and Bob are walking in an ancient maze with a lot of caves and one-way passages
a894383755
·
2016-04-30 17:00
网络
搜索
POJ 2001:
Shortest
Prefixes
ShortestPrefixesTimeLimit: 1000MS MemoryLimit: 30000KTotalSubmissions: 16782 Accepted: 7286DescriptionAprefixofastringisasubstringstartingatthebeginningofthegivenstring.Theprefixesof"carbon"are:"c","c
qq_28954601
·
2016-04-29 21:00
hdu 3631
Shortest
Path 最短路径+插点法+floyd
题目链接题意:给出n个点,m条边,q个操作。对两个点的路径不得经过未标记的点。操作可以标记点或者询问两个点之间的距离,若操作非法则返回指定语句,否则执行操作。作为中间点,一个点一个点插入,理解Floyd的过程即可。#include #include #include #include #defineN330 #defineINF0x7ffffff usingnamespacestd; intm
zchahaha
·
2016-04-29 20:00
最短路径
图论
HDU
floyd
插点法
POJ 2001
Shortest
Prefixes
次元传送门题意:给出一堆由26个小写字母组成的字符串,请你依次输出每个串最短的前缀使得该前缀不是任何其他字符串的前缀,找不到时输出该串。分析:Trie树,不解释代码实现#include #include structtrie{ intson; trie*next[30]; trie(){ memset(next,0,sizeof(next)),son=0; } }root,*t; intmain(
YOUSIKI
·
2016-04-21 14:00
HDU 3585 maximum
shortest
distance 最大团+简单的二分思想
题意:给你n个点,然后你可以从里面找出k个点,然后使得k个点中的最短距离最大。想法:直接二分枚举最大距离,然后把满足的边找出来,然后就看看这些点的最大独立点集,如果个数>=k,那么显然长度可能可以更长一些,所以继续枚举,如果 #include #include #include #include usingnamespacestd; constintnodes=55; intn,k; intx[n
Triple_WDF
·
2016-04-21 09:00
HDU 4725-J - The
Shortest
Path in Nya Graph-增点建图-层次网络-最短路
与hdu5521类似的层次网络最短路问题http://acm.hdu.edu.cn/showproblem.php?pid=4725题意是给n个点,m个边,Cm条边u,v,w,w是边权 除此之外给你一个个layer[i],表示点i属于第layer[i]层! 关于层的性质有两个【如果相邻两层都存在节点,则x层任意节点可以与x+1层任意节点互通,代价为C】当然如果有一层为空,则空层是无法与上下层相通的
viphong
·
2016-04-19 01:00
ICPCCamp2016day 1 - All Pair
Shortest
Path【bitset优化】
题意:给你一个n*n的01矩阵,代表一个有向图i到j是否连边,求所有i到j的最短路的平方和。分析:由于边的长度的都为1,我们考虑bfs每次n^2可以求出i到其他点的最短路径,n^3求出答案,但是时间复杂度承受不了。我们可以发现bfs时遍历了一个点后,其他的点都不用遍历它,我们可以用一个二进制数存下当前还没有遍历的点,bfs的时候我们只需要遍历当前点i要遍历的点&剩下的点。时间复杂度n^3/64,这
u012483216
·
2016-04-13 23:00
hdu 1595 find the longest of the
shortest
最短路dijkstra+枚举
题目链接题意:给出n个点,m条边,求去除任意一条边的最长最短路。这题先用求一次最短路,记录下路径。如果去除的边不在路径上,那么最短路不变。所以我们只要考虑去除最短路上的边的情况。枚举最短路上的边删除,求最短路,注意要还原边。这题用spfa的邻接矩阵形式怎么也过不了,一直TLE。代码不变,换成dijkstra之后就能过了。ps:SPFA算法在负边权图上可以完全取代Bellman-ford算法,另外在
zchahaha
·
2016-04-06 16:00
枚举
最短路
HDU
dijkstra
最长最短路
hdu 2807 The
Shortest
Path 优化矩阵运算+floyd
题目链接题意:给出n个城市,每个城市为一个m阶矩阵。若存在矩阵B使矩阵A*B==C,那么城市A到C有一条路径为1的路。求两个城市之间的最短路。这题貌似一般的暴力过不了,需要用到矩阵乘法的优化。由于这题的数据量很小,判断出两个城市之间的路径后用Floyd就可以轻松求解。矩阵相乘优化算法实现讲解:传送门。这题要注意A,B,C之间都不相等,否则wa。#include #include #include
zchahaha
·
2016-04-05 22:00
最短路
HDU
Matrix
floyd
矩阵乘法优化
hdu 2224 The
shortest
path 双调欧几里得旅行商问题(动态规划)
题目链接题意:给出n个点的坐标,其x坐标单调递增。从x坐标最左点单调走到最右点,然后从x坐标最右点单调走到最左点,每个点只经过一次,求最短的路程。这是双调欧几里得旅行商问题的模板题,给出网上大牛的一段算法学习资料——传送门。#include #include #include #include #defineN220 #defineINF1e12 usingnamespacestd; doub
zchahaha
·
2016-04-04 21:00
算法
dp
动态规划
HDU
双调欧几里得旅行商问题
Shortest
Distance from All Buildings
ProblemMoreLeetCodeDiscussionsYouwanttobuildahouseonanemptylandwhichreachesallbuildingsintheshortestamountofdistance.Youcanonlymoveup,down,leftandright.Youaregivena2Dgridofvalues0,1or2,where:Each0mark
楷书
·
2016-04-04 04:48
HDU 5636:
Shortest
Path【Floyd】
ShortestPathTimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):1466 AcceptedSubmission(s):466ProblemDescriptionThereisapathgraph G=(V,E) with n vertices
lin14543
·
2016-03-30 16:00
Shortest
Distance from All Buildings 解题报告
题目链接: https://leetcode.com/problems/
shortest
-distance-from-all-buildings/Youwanttobuildahouseonan empty
qq508618087
·
2016-03-26 15:00
LeetCode
bfs
杭电5636
Shortest
Path
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5636题目大意:有一条长度为n的链.节点i和i+1之间有长度为1的边.现在又新加了3条边,每条边长度都是1.给出m个询问,每次询问两点之间的最短路.解题思路:将需要用的点的编号提取出来,最多8个(因为询问的点和和新增加边的点可能重复),然后将连边的点距离变为1,未连边的点就和下一个点连边,距离为编号之差
q610376681
·
2016-03-23 15:00
最短路
杭电5363
[LeetCode]
Shortest
Distance from All Buildings 建筑物的最短距离
Youwanttobuildahouseonan empty landwhichreachesallbuildingsintheshortestamountofdistance.Youcanonlymoveup,down,leftandright.Youaregivena2Dgridofvalues 0, 1 or 2,where:Each 0 marksanemptylandwhichyouc
Grandyang
·
2016-03-20 14:00
网络最短路径Dijkstra算法
最近在学习算法,看到有人写过的这样一个算法,我决定摘抄过来作为我的学习笔记:/* *File:
shortest
.c *Description:网络中两点最短路径Dijkstra算法 *ShortestPathDijkstraAlgorithm
morixinguan
·
2016-03-16 22:00
algorithm@ find the
shortest
path in a graph using BFS
FindingShortestPathsByBFSTheBFScodewehaveseenfindoutsifthereexistapathfromavertexstoavertexvprintstheverticesofagraph(connected/stronglyconnected).Whatifwewanttofindtheshortestpathfromstoavertexv(orto
流白
·
2016-03-16 03:00
HDU - 5636
Shortest
Path (判断最短路)
HDU-5636ShortestPathTimeLimit: 2000MS MemoryLimit: 131072KB 64bitIOFormat: %I64d&%I64uSubmit StatusDescriptionThereisapathgraph with vertices.Verticesarenumberedfrom to andthereisanedgewithunitlen
yanghui07216
·
2016-03-15 22:00
hdoj--5636--
Shortest
Path(dfs)
ShortestPathTimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):1316 AcceptedSubmission(s):416ProblemDescriptionThereisapathgraphG=(V,E)withnvertices.V
qq_29963431
·
2016-03-15 17:00
hdu 3631
Shortest
Path(Floyd)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3631ShortestPathTimeLimit:3000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3962 AcceptedSubmission(s):938ProblemDes
yxwkaifa
·
2016-03-14 19:00
Shortest
Word Distance II 解题报告
题目链接: https://leetcode.com/problems/
shortest
-word-distance-ii/Thisisa followup of ShortestWordDistance.Theonlydifferenceisnowyouaregiventhelistofwordsandyourmethodwillbecalledrepeatedly
qq508618087
·
2016-03-14 16:00
LeetCode
hash
Shortest
Word Distance III 解题报告
题目链接: https://leetcode.com/problems/
shortest
-word-distance-iii/Thisisa followup of ShortestWordDistance.Theonlydifferenceisnow
qq508618087
·
2016-03-13 05:00
LeetCode
String
hash
hdu5365
Shortest
Path (floyd)
ProblemDescriptionThereisapathgraph G=(V,E) with n vertices.Verticesarenumberedfrom 1 to n andthereisanedgewithunitlengthbetween i and i+1 (1≤i #include #include #include #include #include #include #i
Kirito_Acmer
·
2016-03-11 20:00
最短路
floyd
Shortest
Word Distance 解题报告
题目链接:https://leetcode.com/problems/
shortest
-word-distance/Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.Forexample
qq508618087
·
2016-03-11 15:00
LeetCode
String
HDU 5636
Shortest
Path(最短路)
题目大意:给定n个点i和i+1(i#include #include #include #include #include #include #include #include #defineLL__int64 #defineinf0x3f3f3f3f #definelsl,mid,rtmp[i][o]+mp[o][j]){ mp[i][j]=mp[i][o]+mp[o][j]; } } } }
Grit_ICPC
·
2016-03-09 17:00
最短路
HDU 5636
Shortest
Path(Floyed,枚举)
ShortestPathTimeLimit:4000/2000MS(Java/Others)MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):1146AcceptedSubmission(s):358ProblemDescriptionThereisapathgraphG=(V,E)withnvertices.Verticesare
Dacc123
·
2016-03-09 08:00
【HDU5636 BestCoder Round 74 (div1)A】【floyd 最短路 复杂度考核】
Shortest
Path 一条链3条边1e6个询问的两点最短路
ShortestPathTimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):1073 AcceptedSubmission(s):340ProblemDescriptionThereisapathgraph G=(V,E) with n vertices
snowy_smile
·
2016-03-08 19:00
题库-HDU
图论-最短路
复杂度计算
【hdu 5636】
Shortest
Path 中文题意&题解&代码(C++)
ShortestPathTimeLimit:4000/2000MS(Java/Others)MemoryLimit:131072/131072K(Java/Others)ProblemDescriptionThereisapathgraphG=(V,E)withnvertices.Verticesarenumberedfrom1tonandthereisanedgewithunitlengthbe
deritt
·
2016-03-07 20:10
【hdu 5636】
Shortest
Path 中文题意&题解&代码(C++)
ShortestPathTimeLimit:4000/2000MS(Java/Others)MemoryLimit:131072/131072K(Java/Others)ProblemDescriptionThereisapathgraphG=(V,E)withnvertices.Verticesarenumberedfrom1tonandthereisanedgewithunitlengthbe
DERITt
·
2016-03-07 20:00
bc
bc
HDU
hdu5636 BestCoder Round #74 (div.2) 1002
Shortest
Path
ShortestPathTimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):1004 AcceptedSubmission(s):329ProblemDescriptionThereisapathgraph G=(V,E) with n vertices
EventQueue
·
2016-03-07 20:00
dp
ACM
图论
BestCoder
hduoj
HDOJ 5636
Shortest
Path(dfs求最短路径)
ShortestPathTimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):821 AcceptedSubmission(s):274ProblemDescriptionThereisapathgraphG=(V,E)withnvertices.Vert
zwj1452267376
·
2016-03-06 22:00
HDU 5636
Shortest
Path floyd应用
ShortestPathTimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)TotalSubmission(s):643 AcceptedSubmission(s):209ProblemDescriptionThereisapathgraph G=(V,E) with n vertices.
FTQOOO
·
2016-03-06 16:00
HDU
floyed
BestCoder Round #74 (div.2) A.LCP Array & B.
Shortest
Path
LCPArray Accepts:131 Submissions:1352 TimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)ProblemDescriptionPeterhasastring ss1s2...sns=s1s2...sn,let isisi1...snsuff
lljjccsskk
·
2016-03-06 15:00
hdoj 5636
Shortest
Path
题目 如果不考虑6个特殊点,两点间距离就是下标差。但是这6个点的存在有可能缩短了两点间距离,所以跑一下6个点到所有点的最短路(6*6*n的floyd),对于每个询问,算一下直接s-t和s-6个点中的某个-t的最小值即可。#include #include #include #include #include #include #include #include #include using
squee_spoon
·
2016-03-06 15:00
floyd
hdu5636
Shortest
Path BestCoder题目
这道题一开始不愿意去动笔比如有大牛写了几十个判断也是可以A的 因为对于起点s,终点e,这道题的答案要么就是abs(e-s),要么就是受到了 加入的三条边的影响 我们只要对这6个点每个点进行一遍spfa然后查询的时候执行6次 s到6个点的距离加上这个点到e的距离这样的距离肯定是最短的 因为这6个点之中的点到e的距离都是你实现跑最短路求出来的 把这6种情况的答案和abs(e-s)比较最小的就是我们求得
mymilkbottles
·
2016-03-06 14:00
BestCoder Round #74 (div.2 b) hdu5636
Shortest
Path 【dfs】
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5637题意:有一条长度为nn的链.节点ii和i+1i+1之间有长度为11的边.现在又新加了3条边,每条边长度都是1.给出mm个询问,每次询问两点之间的最短路.分析:加了三条边,相当于六条边,每次从起点到终点跑个dfs就好了,裸的dfs复杂度为6!,可以发现经过一条边后就不会经过它的反向边,所以每次dfs复杂
u012483216
·
2016-03-06 13:00
HDU 5636
Shortest
Path 暴力
ShortestPath题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5636DescriptionThereisapathgraphG=(V,E)withnvertices.Verticesarenumberedfrom1tonandthereisanedgewithunitlengthbetweeniandi+1(1≤i #include #in
qscqesze
·
2016-03-05 22:00
Shortest
Path(最短路)
ShortestPath Accepts:40 Submissions:610 TimeLimit:4000/2000MS(Java/Others) MemoryLimit:131072/131072K(Java/Others)ProblemDescriptionThereisapathgraph G=(V,E)G=(V,E) with nn vertices.Verticesarenumb
handsomecui
·
2016-03-05 22:00
bc 74
Shortest
Path
之前想了一种枚举方法,结果比赛完后没过终测,题解的方法是这样的,对于新加的六个边我们新建一个图,用floyd跑出每两个点之间的最短路径,在计算l-r的距离的时候我们就可以枚举36种可能求出最优解即可。代码如下:#include #include #include #include #include #include usingnamespacestd; typedeflonglo
xingxing1024
·
2016-03-05 13:00
Shortest
Palindrome
GivenastringS,youareallowedtoconvertittoapalindromebyaddingcharactersinfrontofit.Findandreturntheshortestpalindromeyoucanfindbyperformingthistransformation.Forexample:Given"aacecaaa",return"aaacecaaa"
u014568921
·
2016-03-02 23:00
LeetCode
ICPCCamp 2016 Day1 ftiasch's Contest #4(All Pair
Shortest
Path-位运算)
题意:给一张2000个点的有向图(边的权制均为1),你需要求∑ni=1∑nj=1dis(i,j)dis(i,j)是i到j的最短路距离。不要被复杂度骗了,位运算暴力过,O(n3/64)#include #include #include #include #include #include #include #include #include #include #include #include u
nike0good
·
2016-02-21 23:00
BZOJ3084 : [Algorithmic Engagements 2011]The
Shortest
Period
枚举答案长度$L$,设$A$和$B$分别为第一个循环节和反串的第一个循环节。1.坏点不在$A$,那么可以暴力匹配检验。2.坏点不在$B$,那么把串翻转后不在$A$中,转化为1。3.坏点在$A$和$B$的交里面,那么只要长度为$n-L+1$的前后缀相同,那么就存在长度为$L$的循环节。通过扩展kmp和Hash快速判断即可,时间复杂度$O(dn\logn)$。 #include constintN=
Claris
·
2016-02-20 16:00
[Locked]
Shortest
Word Distance I & II & III
ShortestWordDistanceGivenalistofwordsandtwowords word1 and word2,returntheshortestdistancebetweenthesetwowordsinthelist.Forexample,Assumethatwords= ["practice","makes","perfect","coding","makes"].Give
我有一个小尾巴
·
2016-02-19 14:00
集训队专题(5.1)1003 maximum
shortest
distance
maximumshortestdistanceTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1386 AcceptedSubmission(s):469ProblemDescriptionTherearenpointsintheplane.Yourta
RaAlGhul
·
2016-02-17 16:00
[LeetCode]
Shortest
Word Distance III 最短单词距离之三
ThisisafollowupofShortestWordDistance.Theonlydifferenceisnowword1couldbethesameasword2.Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.word1andword2ma
Grandyang
·
2016-02-16 13:00
LeetCode 214
Shortest
Palindrome (KMP)
Refer: https://segmentfault.com/a/1190000003059361 O(n^2)SolutionpublicStringshortestPalindrome(Strings){ if(s==null||s.length()=1){ if(isPan(s.substring(0,tail+1))){ sb=sb.append(s.substring(tail
xwang2014
·
2016-02-15 08:00
hdu3585 maximum
shortest
distance
maximumshortestdistanceProblemDescriptionTherearenpointsintheplane.Yourtaskistopickkpoints(k>=2),andmaketheclosestpointsinthesekpointsasfaraspossible. InputForeachcase,thefirstlinecontainstwointegersn
acm_fighting
·
2016-02-14 16:00
[LeetCode]
Shortest
Word Distance II 最短单词距离之二
Thisisa followup of ShortestWordDistance.Theonlydifferenceisnowyouaregiventhelistofwordsandyourmethodwillbecalled repeatedly manytimeswithdifferentparameters.Howwouldyouoptimizeit?Designaclasswhichre
Grandyang
·
2016-02-13 14:00
hdoj 3585 maximum
shortest
distance(二分+最大团)
maximumshortestdistanceProblemDescriptionTherearenpointsintheplane.Yourtaskistopickkpoints(k>=2),andmaketheclosestpointsinthesekpointsasfaraspossible. InputForeachcase,thefirstlinecontainstwointegersn
a709743744
·
2016-02-13 04:00
[LeetCode]
Shortest
Word Distance 最短单词距离
Givenalistofwordsandtwowords word1 and word2,returntheshortestdistancebetweenthesetwowordsinthelist.Forexample,Assumethatwords= ["practice","makes","perfect","coding","makes"].Given word1 = “coding”,
Grandyang
·
2016-02-12 14:00
上一页
7
8
9
10
11
12
13
14
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他