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
HDU 1595 find the longest of the
shortest
在最短的时间最长。 含义非常模糊标题,做4小时度过理解问题……对中国不会死! !。 它说,从 N 至 1 可能有一些办法的道路被封锁,不能。乞讨N 至 1 在最短的时间最长。 一般想法就是枚举 每条路不能通过时候的最短路。时间花费太高。 m*O(SPFA)。 能够先做一次SPFA。把最短路径记录下来。 其它的路无论是不是 封堵了,最短路都是这么多。 然后再
·
2015-10-23 08:48
test
LeetCode-
Shortest
Word Distance II
因为需要多次call所以就存成hashmap存positionlist关键是找min的时候实际上就是给两个list找其中数字最小difference 方法就是每次更新那个小的让他变大去靠近大的(因为list是sorted从小到大)移动数字比较小的那个的指针publicclassWordDistance{ HashMap>map=newHashMap>(); publicWordDistance(S
bsbcarter
·
2015-10-22 02:00
poj 2001
Shortest
Prefixes(字典树)
题目链接:http://poj.org/problem?id=2001 思路分析: 在Trie结点中添加数据域childNum,表示以该字符串为前缀的字符数目; 在创建结点时,路径上的所有除叶子节点以外的结点的childNum增加1,叶子结点的childNum设置为1; 在查询某个结点的最短前缀时: (1)若查找路径上的所有结点的childNum大于1,表明该字符串的最短路径为其自身;
·
2015-10-21 13:14
test
ZOJ 1760 How Many
Shortest
Path
ZOJ_1760 只要保留S-T所有可能的最短路上的边,然后做最大流即可,题目数据存在f[i][i]!=0的情况,因此如果用floyd预处理的话要注意初始化f[i][i]=0。 #include<stdio.h> #include<string.h> #include<algorithm> #define MAXD 110
·
2015-10-21 13:30
Path
[leedcode 111] Minimum Depth of Binary Tree
The minimum depth is the number of nodes along the
shortest
path from the root node down to the nearest
·
2015-10-21 12:58
binary
[LeetCode]
Shortest
Palindrome
Find and return the
shortest
palindrome you can find by performing this transformation. For exampl
·
2015-10-21 12:19
LeetCode
shorter concat [reverse longer]
In other words, the
shortest
string has to b
·
2015-10-21 12:33
concat
[leetcode]Minimum Depth of Binary Tree @ Python
The minimum depth is the number of nodes along the
shortest
path from the root no
·
2015-10-21 11:47
LeetCode
Leetcode:Word Ladder 单词接龙
Word Ladder Given two words (start and end), and a dictionary, find the length of
shortest
transformation
·
2015-10-21 11:36
LeetCode
Leetcode:Minimum Depth of Binary Tree 二叉树的最短路径
The minimum depth is the number of nodes along the
shortest
path from the root node down to the nearest
·
2015-10-21 11:25
LeetCode
Minimum Depth of Binary Tree leetcode java
The minimum depth is the number of nodes along the
shortest
path from the root node down to the nearest
·
2015-10-21 10:56
LeetCode
SGU 185 Two
shortest
SGU_185 这个题目被内存卡的严重头晕…… 其实思路还是满直观的,由于要两条路不相交,只要用网络流就行,再加上要两条最短路,那么就最小费用最大流,最后看两条路的费用和是不是最短路的两倍即可。但如果裸着这样写,由于无向边相当于两条有向边,不好意思,内存爆了……开小点吧,不好意思,RE了…… 晕……那还是换网
·
2015-10-21 10:55
test
*LeetCode-
Shortest
Word Distance
一个词可能存在很多次所以不能只记录minmaxpos要每次找到一个词就更新一下距离看是否最短然后updatemin因为每次pos都向后更新了所以最短肯定是和当前的p而不会和之前的p最短publicclassSolution{ publicintshortestDistance(String[]words,Stringword1,Stringword2){ if(words==null||words
bsbcarter
·
2015-10-17 03:00
HDU 4871
Shortest
-path tree (树分治之点分治 最短路径树问题)
题目大意:给出一个连通的无向图,然后找一颗生成树,生成树满足点1到每个点的书上距离都是原图中的最短路,然后在满足最短路的条件下,点1到每个点的树上路径的序列字典序最小找出这个树之后,给出K询问树上有K个结点的路径的最大边权值,以及这样的最大边权值的路径的方案数大致思路:首先spfa取得所有的1到其他点的最短距离然后按照字典序进行dfs找出最短路径树之后就是裸的树分治的问题了用dis[i]表示i个结
u013738743
·
2015-10-15 00:00
tree
HDU
shortest-path
点分治
4871
hdu 5373 The
shortest
problem(杭电多校赛第七场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373TheshortestproblemTimeLimit:3000/1500MS(Java/Others) MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):995 AcceptedSubmission(s):498Probl
qiqi_skystar
·
2015-10-12 14:00
高精度求余-HDOJ-5373-The
Shortest
Problem
TheshortestproblemTimeLimit:3000/1500MS(Java/Others)MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):1676AcceptedSubmission(s):746ProblemDescriptionInthisproblem,weshouldsolveaninterestinggame.
Roy_Yuan
·
2015-10-11 19:00
c
HDU 4725 The
Shortest
Path in Nya Graph 建图加SPFA
TheShortestPathinNyaGraphTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):4143 AcceptedSubmission(s):965ProblemDescriptionThisisaveryeasyproblem,yourtas
wust_ZJX
·
2015-10-11 13:00
LeetCode 题解(269) :
Shortest
Word Distance III
题目:ThisisafollowupofShortestWordDistance.Theonlydifferenceisnowword1couldbethesameasword2.Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.word1andword2
u011029779
·
2015-10-09 13:00
Algorithm
LeetCode
面试题
LeetCode 题解(268) :
Shortest
Word Distance II
题目:ThisisafollowupofShortestWordDistance.Theonlydifferenceisnowyouaregiventhelistofwordsandyourmethodwillbecalledrepeatedlymanytimeswithdifferentparameters.Howwouldyouoptimizeit?Designaclasswhichrecei
u011029779
·
2015-10-09 13:00
Algorithm
LeetCode
面试题
LeetCode 题解(267) :
Shortest
Word Distance
题目:Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.Forexample,Assumethatwords=["practice","makes","perfect","coding","makes"].Givenword1=“coding”,word2
u011029779
·
2015-10-09 13:00
Algorithm
LeetCode
面试题
[LeetCode 214]
Shortest
Palindrome
GivenastringS,youareallowedtoconvertittoapalindromebyaddingcharactersinfrontofit.Findandreturntheshortestpalindromeyoucanfindbyperformingthistransformation.Forexample:Given"aacecaaa",return"aaacecaaa"
sbitswc
·
2015-10-05 13:00
LeetCode
String
palindrome
CodeForces 3A
Shortest
path of the king(贪心)——Codeforces Beta Round #3
A.Shortestpathofthekingtimelimitpertest1secondmemorylimitpertest64megabytesinputstandardinputoutputstandardoutputThekingisleftaloneonthechessboard.Inspiteofthisloneliness,hedoesn'tloseheart,becauseheh
queuelovestack
·
2015-10-03 07:00
ACM
greedy
Shortest
Paths
HDU 1595 find the longest of the
shortest
就是简单求以下这个式子,所以直接按照公式枚举就好了。maxe∈path(sp(V,E))sp(V,E/{e})#include #include #include #include #include #include usingnamespacestd; #defineedge(i,u)for(inti=head[u];i!=-1;i=graph[i].next) #definerange(
speedcell4
·
2015-10-01 02:00
找出能唯一标示一个字符串的最短前缀 Trie POJ 2001
Shortest
Prefixes
http://poj.org/problem?id=2001题意:找出能唯一标示一个字符串的最短前缀。解析:Trie树。val表示有多少个单词节点。先将所有单词保存在Trie树中,然后一个一个地查找,当到达某个节点时val==1。表示到当前位置只有一条路,那么从根到该节点组成的字符串便是该单词的最短前缀。总结:RE了一个下午,才知道,遍历字符串的时候要先求出字符串的长度,然后根据这个长度进行遍历,
詹明捷
·
2015-09-29 21:07
Trie
[LeetCode]
Shortest
Palindrome 最短回文串
GivenastringS,youareallowedtoconvertittoapalindromebyaddingcharactersinfrontofit.Findandreturntheshortestpalindromeyoucanfindbyperformingthistransformation.Forexample:Given "aacecaaa",return "aaacecaa
lcj_cjfykx
·
2015-09-18 06:00
Leetcode:
Shortest
Word Distance III
QuestionThisisafollowupofShortestWordDistance.Theonlydifferenceisnowword1couldbethesameasword2.Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.word1and
ayst123
·
2015-09-15 14:00
Leetcode:
Shortest
Word Distance II
QuestionThisisafollowupofShortestWordDistance.Theonlydifferenceisnowyouaregiventhelistofwordsandyourmethodwillbecalledrepeatedlymanytimeswithdifferentparameters.Howwouldyouoptimizeit?Designaclasswhich
ayst123
·
2015-09-15 14:00
Leetcode:
Shortest
Word Distance
QuestionGivenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.Forexample,Assumethatwords=[“practice”,“makes”,“perfect”,“coding”,“makes”].Givenword1=“coding”,
ayst123
·
2015-09-15 14:00
2015多校联合第六场 hdu5373 The
shortest
problem 水
ProblemDescriptionInthisproblem,weshouldsolveaninterestinggame.Atfirst,wehaveanintegern,thenwebegintomakesomefunnychange.Wesumupeverydigitofthen,theninsertittothetailofthenumbern,thenletthenewnumberbe
zhou_yujia
·
2015-09-08 20:00
算法
模拟
HDU
多校
Shortest
Palindrome
题意为,允许在字符串的头部添加字符,使其成为回文。最简单的方法是讲该字符串翻转为s2,s2+s1即为回文,但题目要求的是最短的回文串。于是问题便转换为一个,求以原字符串首字符开头(s[0])的最长子串的长度(亦即使得s.substr(0,length)为回文的最大length值)这么一个子问题。 ——可以想象,当求得这么一个length后,我们将s.substr(length)翻转添加到s头
u014674776
·
2015-08-27 17:00
LeetCode
C++
ZOJ 2760 How Many
Shortest
Path (floyd+dinic)
题目大意:题目即题解。解题思路:floyd求出最短路,对于能在最短路上的边u->v建流量为1的边。s-t的最大流即为答案。#include #include #include #include #include #include #include #include #defineLLlonglong #definedbdouble #definemaxn10000000 #defineEPS1e-
qq919017553
·
2015-08-25 21:00
最短路径算法—SPFA(
Shortest
Path Faster Algorithm)算法分析与实现(C/C++)
建议看SPFA前先看看Dijkstra和Bellman-Ford这两个最短路算法。SPFA的思路比较简单,网上的说法也比较统一,NOCOW和百度百科上都有。这里在网上找到讲的比较通俗易懂的:SPFA(ShortestPathFasterAlgorithm)是Bellman-Ford算法的一种队列实现,减少了不必要的冗余计算。算法大致流程是用一个队列来进行维护。初始时将源加入队列。每次从队列中取出一
qq_21120027
·
2015-08-25 16:00
算法
dijkstra
leetcode--
Shortest
Word Distance II
ThisisafollowupofShortestWordDistance.Theonlydifferenceisnowyouaregiventhelistofwordsandyourmethodwillbecalledrepeatedlymanytimeswithdifferentparameters.Howwouldyouoptimizeit? Designaclasswhichreceive
kangaroo835127729
·
2015-08-22 15:00
leetcode--
Shortest
Word Distance
Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist. Forexample, Assumethatwords=["practice","makes","perfect","coding","makes"]. Givenword1=“coding”,word2
kangaroo835127729
·
2015-08-22 15:00
java
LeetCode
算法
数组
sgu 185 Two
shortest
(最短路+最大流)
一开始读错题啦,以为是求所有的最短路。原来是求边不重复的最短路条数。这样的话就和hdu3599一样一样的了。建图:点击打开链接唯一不同的是,需要输出两个方案来。那么就作两次DFS就好了,第一次DFS访问顶点时,同时将访问的边给删掉。一开始WAontest6,原因是新建图的时候忘了加Map[i][j]!=0的条件,导致有的两个顶点本没有边,结果也给加到新建的图里去了_(:3」∠)_#include
u014679804
·
2015-08-19 17:00
POJ 2001
Shortest
Prefixes (字典树 TRIE)
题目链接:http://poj.org/problem?id=2001【题目大意】给你一些单词,让你求出他们最短的前缀,当然,这个前缀不能有歧义,例如给出单词cartoncartcarcarton的前缀就不能是cart,因为cart的前缀是cart,同理cart的前缀也不能是car。要找到每个单词独一无二且是最短的前缀,car的前缀不能是,”c“ “ca”,因为他们在别的单词中也有出现,如果找不到
u012515223
·
2015-08-18 22:00
trie
字典树
字符串数组中两个字符的最短距离
[leetcode] https://leetcode.com/problems/
shortest
-word-distance/Forexample,Assumethatwords= ["practice
BlueWoods
·
2015-08-18 21:00
LeetCode
Leetcode -
Shortest
Word Distance II
ThisisafollowupofShortestWordDistance.Theonlydifferenceisnowyouaregiventhelistofwordsandyourmethodwillbecalledrepeatedlymanytimeswithdifferentparameters.Howwouldyouoptimizeit?Designaclasswhichreceives
likesky3
·
2015-08-18 07:00
Leetcode -
Shortest
Word Distance III
ThisisafollowupofShortestWordDistance.Theonlydifferenceisnowword1couldbethesameasword2.Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.word1andword2may
likesky3
·
2015-08-17 22:00
Leetcode -
Shortest
Word Distance
Givenalistofwordsandtwowordsword1andword2,returntheshortestdistancebetweenthesetwowordsinthelist.Forexample,Assumethatwords=["practice","makes","perfect","coding","makes"].Givenword1=“coding”,word2=“p
likesky3
·
2015-08-17 22:00
POJ 2001
Shortest
Prefixes
题目链接:http://poj.org/problem?id=2001解题思路:给你一定数量的串,然后让你求出能分辨每一个串的最小前缀。。。用字典树存储每一个串,并作标记,直到找到一个标记为1的字母,输出即可。。。AC代码:#include #include #include usingnamespacestd; structnode { intcnt; structnode*next[26];
piaocoder
·
2015-08-17 20:00
字典树
hdu 5373 The
shortest
problem
#include usingnamespacestd; ints[100],k; intfnc(intx) { intret=0; while(x>0) { s[k++]=x%10; ret+=x%10; x/=10; } returnret; } intmain() { int_=0,n,m,tp,f,ans; while(~scanf("%d%d",&n,&m)) { if(n==-1&&
xinag578
·
2015-08-17 17:00
hdu 5373 The
shortest
problem (模拟)
题目链接ProblemDescriptionInthisproblem,weshouldsolveaninterestinggame.Atfirst,wehaveanintegern,thenwebegintomakesomefunnychange.Wesumupeverydigitofthen,theninsertittothetailofthenumbern,thenletthenewnumb
qq_26564523
·
2015-08-13 18:00
模拟
HDU 5373 The
shortest
problem(判断一个数能否被11整除)
题目地址;点击打开链接思路:参考队友的代码写的,资料地址:点击打开链接 怎样判断一个数能不能被11整除?判断一个数能不能被11整除与判断一个数能不能被7整除一样,都没有直接判断的方法,需要借助间接的方法,这种间接的方法有两种,其一是“割减法”,其二是奇偶位差法。(1)割减法:判断被11整除的割减法与判断被7整除的割减法不同。即:一个数割去末尾数字,再从留下来的数中减去这个末位数字,这样一次一次地减
qq_25605637
·
2015-08-13 09:00
HDU5373 The
shortest
problem 数学水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373题目大意:给你一个整数n和操作次数t,对于每次操作,我们把n的各个位上的数字加起来,把得到的数放到n的末尾形成一个新的整数n',例如n=123,t=3,我们有变换123=>1236=>12312=>1231215,最终得到的n'=1231215,现在我们要判断n'能否被11整除。分析:对于整除的一
AC_Gibson
·
2015-08-13 09:00
The
shortest
problem
TheshortestproblemTimeLimit:3000/1500MS(Java/Others)MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):969AcceptedSubmission(s):491ProblemDescriptionInthisproblem,weshouldsolveaninterestinggame.A
huayunhualuo
·
2015-08-12 21:00
HDU 5373 The
shortest
problem (递归调用,详解)
题目地址http://acm.hdu.edu.cn/showproblem.php?pid=5373TheshortestproblemTimeLimit:3000/1500MS(Java/Others) MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):935 AcceptedSubmission(s):479Proble
sinat_30126425
·
2015-08-12 20:00
HDU 5373 The
shortest
problem
分析:题目问最后得到的数能不能被11整除,11的倍数的特点是奇数位和偶数位的差能被11整除,知道这就好求了。#include #include chars[10]; intmain() { inti,n,t,len,cas=1,sum,tem,k,s1,s2,x1,x2; while(scanf("%d%d",&n,&t)) { if(n==-1&&t==-1) break; sprintf(s,
ZengAMing
·
2015-08-12 20:00
ACM
hdu 5373 The
shortest
problem(模拟)
题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n是否可以被11整除。解析:百度了一下能被11整除的数的性质,就是:当一个数的奇数位之和与偶数位之和的差的绝对值能被11整除,那么该数就可以被11整除。如35816,奇数位之和为17,偶数位之和是6,差的绝对值为11,所以能被11整除。对于每次操作,记录下奇数位置上的和,以及偶数位置上的和,那么
HelloWorld10086
·
2015-08-12 10:00
HDU
5373
hdu 5373 The
shortest
problem 2015多校联合训练赛#7 模拟
TheshortestproblemTimeLimit:3000/1500MS(Java/Others) MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):532 AcceptedSubmission(s):271ProblemDescriptionInthisproblem,weshouldsolveaninteresti
firenet1
·
2015-08-12 08:00
HDU
2015多校联合训练赛
5373
上一页
13
14
15
16
17
18
19
20
下一页
按字母分类:
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
其他