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
Roads
URAL 1980 Road to Investor (二分 + SPFA)
#include #defineMAX_CROSSES10000 #defineMAX_
ROADS
10000 #definePRECISION1e-7 #defineFABS(x)((x)>0?
tiutiu2011
·
2015-09-17 16:00
TO
SPFA
二分
Road
investor
1980
ural
HDU 1025 Constructing
Roads
In JGShining's Kingdom
题意:给你N组数,每组数有两个p,r。问在这2n个点中,连线,求最多可以连好多线在不相交的情况下。分析:把p排序,求r的最长上升子序就行了#include #include #include usingnamespacestd; constintmaxm=1e6+10; inta[maxm]; intdp[maxm]; intn; structnode { intx,y; }t[maxm]; in
zyx520ytt
·
2015-09-15 20:00
hdu 1025 Constructing
Roads
In JGShining's Kingdom 最长上升序列nlogn
#include usingnamespacestd; intd[500000+5],a[500000+5]; intBinary_search(ints,intt,inti) { intmid; while(s>1; if(i>=d[mid])s=mid+1; elset=mid; } returns; } intmain() { inti,n,b,p,r,k,cas=0; while(~s
xinag578
·
2015-09-10 10:00
POJ 1724
ROADS
(费用最短路:优先队列+BFS)
这个做法是错误的!!!!数据太水,就水过去了。要看正解请看另一个题目的解法题目意思很简单,就是求费用最短路,数据比较小,考虑暴力bfs。状态定义为(花费,最短路,终点)的一个三元组。优先队列按照最短路长度排序,每次从队列里取出最短路长度最短的状态,然后把跟该状态终点相邻的点加入队列。因为数据比较小,所以不用记录访问情况也能ac。#pragmawarning(disable:4996) #inclu
acraz
·
2015-09-09 12:00
All
Roads
Lead to Rome (30)
题目链接:http://www.patest.cn/contests/pat-a-practise/1087题目:IndeedtherearemanydifferenttouristroutesfromourcitytoRome.Youaresupposedtofindyourclientstheroutewiththeleastcostwhilegainingthemosthappiness.I
陈小旭
·
2015-09-08 22:41
dijkstra
PAT
PAT
All
Roads
Lead to Rome (30)
题目链接:http://www.patest.cn/contests/pat-a-practise/1087题目:IndeedtherearemanydifferenttouristroutesfromourcitytoRome.Youaresupposedtofindyourclientstheroutewiththeleastcostwhilegainingthemosthappiness.I
Apie_CZX
·
2015-09-08 22:00
dijkstra
pat
Codeforces 567E President and
Roads
(用Dijkstra求最短路条数 + 强连通桥)
@(KACMer)by题解工厂题意:给你一个有向图,问你这条边是不是最短路必须经过的边.如果不是能不能通过减少它的长度(但必须边的长度大于0)来让它成为必须经过的边.分析:先谈,判断一个路径(u,v)是不是最短路上的路.显然如果u到起点的距离加上v到终点的距离,再加上(u,v)边的长度等于起点到终点的最短路长度,那么这个边就可能是最短路上的路,但是不一定就是,因为也可能存在和它等效的边.那么如何判
jibancanyang
·
2015-09-06 15:00
HDU 1102 Constructing
Roads
(最小生成树-Prim)
Description给你一个有n个村庄的地图,cost[i][j]表示从村庄i到村庄j的距离,然后给你m条已有道路,让你在这个基础上添加适当的道路,使得所有村庄之间都是联通的,求添加道路的最短距离的值Input第一行为村庄个数n,之后一个n*n矩阵表示村庄之间的距离矩阵,第n+2行为一整数m表示已经修好的道路数,之后m行每行两个整数a和b表示a村庄与b村庄之间的道路已经修好Output输出添加道
V5ZSQ
·
2015-09-06 08:00
HDU 1102 Constructing
Roads
-- prime
ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):17739 AcceptedSubmission(s):6744ProblemDescriptionThereareNvillages,whicharenumberedfr
qq_26437925
·
2015-09-05 10:00
POJ 2421 Constructing
Roads
//思路:把联通了的两个点的权值标记成0,然后用克鲁斯卡尔算法过或者其他的算法也行//AC代码:#include #include #include usingnamespacestd; #defineN200005 intn,p[N],L,a[200][200]; structnode { intw,v,c; }t[N]; intcmp(nodep,nodeq) { returnp.c
zyx520ytt
·
2015-08-28 15:00
HDU 1301 Jungle
Roads
//最小生成树水题//AC代码:#include #include #include usingnamespacestd; #defineN20000 chars1[8],s2[8]; intL,p[N],n; structnode { intw,v,c; }t[N]; intcmp(nodep,nodeq) { returnp.c
zyx520ytt
·
2015-08-28 11:00
POJ3411--Paid
Roads
题目大意:有n个城市,m条路,每条路有五个信息,出发城市a,达到城市b,如果之前到过城市c,那么这条路的费用就是p,否则费用为r。求从城市1到城市n的最小花费。 分析:直接暴力深搜。当然,要带上一些剪枝。首先是,可行性剪枝,对于一个路为m条的图,每个节点的到达次数的上限为m/2,否则就会进入一个循环圈(m=1时除外)。接着是最优化剪枝,如果当前的总花费比已经算出的最小花费还大,那么也可以剪掉。代码
hhhhhhj123
·
2015-08-28 11:00
HDU 5378(Leader in Tree Land-利用概率dp)
TotalSubmission(s):498 AcceptedSubmission(s):208ProblemDescriptionTreelandhasncities,connectedbyn−1
roads
.Y
nike0good
·
2015-08-27 18:00
hdu 5413 CRB and
Roads
位运算优化复杂度
题意:给一个包含n个点m条边的无环单向简单图,然后问有多少条多余边。(u,v)是多余边当且仅当u−>v不经过(u,v)这条边。都说了是无环单向图。因此很容易想到拓扑排序:对于当且点u,如果存在(u,v),v可以由u通过另一条路径到达,那么(u,v)这条边就是多余边,但是这样暴力下来复杂度大概是O(n∗(n+m)),然后再乘以一个T(T≤20),就T了。。我的第一个想法是这么做的。然后交上去真的T了
CHCXCHC
·
2015-08-25 20:00
位运算
bitset
hdu 1102 Constructing
Roads
http://acm.hdu.edu.cn/showproblem.php?pid=1102ProblemDescriptionThereareNvillages,whicharenumberedfrom1toN,andyoushouldbuildsomeroadssuchthateverytwovillagescanconnecttoeachother.WesaytwovillageAandBa
qq_21120027
·
2015-08-24 16:00
最小生成树
HDU
Prim
HDU-1301 Jungle
Roads
(最小生成树[Prim])
JungleRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)ProblemDescriptionTheHeadElderofthetropicalislandofLagrishanhasaproblem.Aburstofforeignaidmoneywasspentonextraroad
idealism_xxm
·
2015-08-19 21:00
最小生成树
图论
HDU
Prim
HDU 1025 Constructing
Roads
In JGShining's Kingdom
HDU1025ConstructingRoadsInJGShining’sKingdomProblemDescriptionJGShining’skingdomconsistsof2n(nisnomorethan500,000)smallcitieswhicharelocatedintwoparallellines.Halfofthesecitiesarerichinresource(wecall
qq_21120027
·
2015-08-19 19:00
HDU
hdu 1102 Constructing
Roads
(kruskal || prim)
求最小生成树,有一点点的变化,就是有的边已经给出来了,所以,最小生成树里面必须有这些边,kruskal和prim算法都可以,prim更简单一些,有一点需要注意,用克鲁斯卡尔算法的时候需要将已经存在的边预处理一下,并查集转化为同一个祖先,记得要找他们的祖先再转化。普里姆算法只需要将那些已经存在的边都初始化为0就可以了。kruskal:#include #include #include #inclu
sinat_22659021
·
2015-08-19 17:00
HDU-1102 Constructing
Roads
(最小生成树[Prim])
ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)ProblemDescriptionThereareNvillages,whicharenumberedfrom1toN,andyoushouldbuildsomeroadssuchthateverytwovilla
idealism_xxm
·
2015-08-19 16:00
最小生成树
图论
HDU
Prim
ROADS
ROADSTimeLimit:1000MSMemoryLimit:65536KTotalSubmissions:11977Accepted:4429DescriptionNcitiesnamedwithnumbers1…Nareconnectedwithone-wayroads.Eachroadhastwoparametersassociatedwithit:theroadlengthandthe
huayunhualuo
·
2015-08-16 14:00
All
Roads
Lead to Rome (30) -- Dijkstra经典
题目地址:http://www.patest.cn/contests/pat-a-practise/1087IndeedtherearemanydifferenttouristroutesfromourcitytoRome.Youaresupposedtofindyourclientstheroutewiththeleastcostwhilegainingthemosthappiness.Inpu
qq_26437925
·
2015-08-15 17:00
dijkstra
President and
Roads
最短路变形
链接:http://codeforces.com/contest/567/problem/E题意:总统只走最短路,给了一个有向图,对于每条边判断是否一定走这条路,如果一定输出yes如果不一定,那么是否可以减少这个边的权值使得总统一定走这条路,如果可以输出最少减少多少can**,如果不行输出no。分析:对于每个图可能有不只一条的最短路,要找出每条边是否一定要走,如果这条边是在其中一条最短路上,又要判
liujc_
·
2015-08-15 13:00
hdu1301 Jungle
Roads
(最小生成树)
JungleRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5591 AcceptedSubmission(s):4031ProblemDescriptionTheHeadElderofthetropicalislandofLagrishanh
su20145104009
·
2015-08-14 09:00
HDU
MST
1301
hdu1301
Jungle
Roads
Codeforces 567E President and
Roads
@(题解)[Codeforces|Dijkstra|最短路|最短路径数|好题|567E]Codeforces567EPresidentandRoads题意:给出一个有向图,给出起点s,和终点t,总是从s沿着最短路径走到t,对于每一条边询问是否一定会经过这条边,如果是输出yes。如果不是,能否通过把减少这条边的权值(但不能减少到0)使这条边成为沿着最短路走一定会经过的边。如果能,输出需要减少的最少权
lxc779760807
·
2015-08-13 20:00
dijkstra
codeforces
杭电 1102 Constructing
Roads
【最小生成树&&Kruskal】
ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):17411 AcceptedSubmission(s):6617ProblemDescriptionThereareNvillages,whicharenumberedfr
qq_24678203
·
2015-08-13 11:00
Dark
roads
--hdoj
DarkroadsTimeLimit:2000/1000ms(Java/Other) MemoryLimit:32768/32768K(Java/Other)TotalSubmission(s):4 AcceptedSubmission(s):1ProblemDescriptionEconomictimesthesedaysaretough,e
qq_29963431
·
2015-08-12 20:00
杭电 1301 Jungle
Roads
【最小生成树&&Kruskal】
JungleRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5530 AcceptedSubmission(s):3993ProblemDescriptionTheHeadElderofthetropicalislandofLagrishanh
qq_24678203
·
2015-08-12 19:00
HDOJ 2988 Dark
roads
(最小生成树--kruskul)
DarkroadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):800 AcceptedSubmission(s):330ProblemDescriptionEconomictimesthesedaysaretough,eveninByteland.T
helloiamclh
·
2015-08-12 19:00
HDU 1301:Jungle
Roads
【Prim】
JungleRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5516 AcceptedSubmission(s):3981ProblemDescriptionTheHeadElderofthetropicalislandofLagrishan
lin14543
·
2015-08-12 16:00
最小生成树
图论
HDU
Prim
HDU 1102:Constructing
Roads
【Kruskal & Prim】
ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):17214 AcceptedSubmission(s):6538ProblemDescriptionThereareNvillages,whicharenumberedfr
lin14543
·
2015-08-11 21:00
最小生成树
图论
HDU
kruskal
Prim
HDOJ 1102 Constructing
Roads
(最小生成树)
ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):17206 AcceptedSubmission(s):6532ProblemDescriptionThereareNvillages,whicharenumberedfr
zwj1452267376
·
2015-08-11 21:00
Jungle
Roads
TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5455 AcceptedSubmission(s):3936ProblemDescriptionTheHeadElderofthetropicalislandofLagrishanhasaproblem.
l15738519366
·
2015-08-11 20:00
HDOJ 1301 Jungle
Roads
(最小生成树)
JungleRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5431 AcceptedSubmission(s):3919ProblemDescriptionTheHeadElderofthetropicalislandofLagrishanh
zwj1452267376
·
2015-08-11 19:00
HDU1301 Jungle
Roads
#include#include#include#include#includeusingnamespacestd;constintmaxn=30;constintmaxm=500;structEdge{ int v1,v2; intweight; Edge(int_v1=0,int_v2 =0,int_weight=0):v1(_v1),v2(_v2),weight(_weight)
efine_dxq
·
2015-08-11 17:00
最小生成树
图论
HDU
kruskal
并查集
hdu 1102 Constructing
Roads
(Kruskal算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):17132 AcceptedSubmission(s):6500Pro
chaiwenjun000
·
2015-08-11 16:00
图论
kruskal
Constructing
Roads
HDU杭电1102【Kruscal || Prim】
ProblemDescriptionThereareNvillages,whicharenumberedfrom1toN,andyoushouldbuildsomeroadssuchthateverytwovillagescanconnecttoeachother.WesaytwovillageAandBareconnected,ifandonlyifthereisaroadbetweenAand
yuzhiwei1995
·
2015-08-11 16:00
HDOJ 1102 Constructing
Roads
(最小生成树--prime)
ConstructingRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):17111 AcceptedSubmission(s):6489ProblemDescriptionThereareNvillages,whicharenumberedfr
helloiamclh
·
2015-08-11 15:00
HDOJ 1301 Jungle
Roads
(最小生成树--prime)
JungleRoadsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5377 AcceptedSubmission(s):3882ProblemDescriptionTheHeadElderofthetropicalislandofLagrishanh
helloiamclh
·
2015-08-11 11:00
POJ 2421--Constructing
Roads
【水题 && 最小生成树 && kruskal】
ConstructingRoadsTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 20889 Accepted: 8817DescriptionThereareNvillages,whicharenumberedfrom1toN,andyoushouldbuildsomeroadssuchthateverytwovillagescanc
hpuhjh
·
2015-08-10 18:00
hdu 1025 Constructing
Roads
In JGShining's Kingdom(最长上升子序列nlogn算法)
学习了最长上升子序列,刚开始学的n^2的方法,然后就超时了,肯定超的,最大值都是500000,平方之后都12位了,所以又开始学nlogn算法,找到了学长党姐的博客orz,看到了rating是浮云。。。确实啊,这些不必太关注,作为一个动力就可以啦。没必要看的太重,重要的事学习知识。思路:这道题目可以先对一行排序,然后对另一行求最长上升子序列。。。n^2算法:序列a[n],设一个数组d[n]表示到n位
sinat_22659021
·
2015-08-10 13:00
二 LightOJ 1002 最小生成树
DescriptionIamgoingtomyhome.Therearemanycitiesandmanybi-directionalroadsbetweenthem.Thecitiesarenumberedfrom 0to n-1 andeachroadhasacost.Thereare m
roads
.Youaregiventhenumberofmycity
became_a_wolf
·
2015-08-09 21:00
LightOJ 1002 Country
Roads
(最短路变形(SPFA||贝尔曼))
TimeLimit:3000MS MemoryLimit:32768KB 64bitIOFormat:%lld&%lluSubmitStatusPracticeLightOJ1002DescriptionIamgoingtomyhome.Therearemanycitiesandmanybi-directionalroadsbetweenthem.Thecitiesarenumbere
Grit_ICPC
·
2015-08-08 20:00
最短路
【LightOJ 1002】 Country
Roads
【LightOJ1002】CountryRoads。。。又一个另类OJ。。。最长路贴个SPFA的#include #include #include #include #include #include usingnamespacestd; intmp[555][555]; intdis[555]; boolvis[555]; intn,m,tp,s; voidSPFA() { memset
ChallengerRumble
·
2015-08-08 16:00
最短路
Road System HUST 1631 最小生成树
&%lluSubmit Status Practice HUST1631DescriptionThere are M cities in a map.Alice wants to find some
roads
sloanqin
·
2015-08-08 11:00
President and
Roads
(边双无向图缩点(有重边)+最短路)
E.PresidentandRoadstimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputBerlandhas n cities,thecapitalislocatedincity s,andthehistorichometownofthePresidentisinc
kalilili
·
2015-08-08 10:00
hdu 1025 Constructing
Roads
In JGShining's Kingdom(DP)
传送门ConstructingRoadsInJGShining'sKingdomTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):18809 AcceptedSubmission(s):5314ProblemDescriptionJGShining'ski
qq_26564523
·
2015-08-07 20:00
动态规划
最长上升子序列
President and
Roads
(最短路+强连通求割边)
题目地址:codeforces#pi(DIV2)E题目很水。。就是先求两边最短路,然后把可能为最短路的边挑出来,然后判断是否yes只需要转化成无向图跑一遍tarjan,找出割边,割边就是yes,然后剩下的边就让它的值为最短路-1就行了,如果-1后变成了非正数,就是no.但是!!!居然卡spfa!!那是不是说cf以后就不能用可以卡的算法了。。完全可以出组数据来卡这些算法。。。比如spfa,isap。
u013013910
·
2015-08-07 15:00
编程
ACM
最短路
Tarjan
算法与数据结构
poj 1251 Jungle
Roads
解题报告(kruskal+prim)
JungleRoadsTimeLimit: 1000MS MemoryLimit: 10000KTotalSubmissions: 21232 Accepted: 9817DescriptionTheHeadElderofthetropicalislandofLagrishanhasaproblem.Aburstofforeignaidmoneywasspentonextraroadsbetwee
qq_21899803
·
2015-08-05 22:00
最小生成树
ACM
图论
Prim
kruskal
poj 2631
Roads
in the North 【树的直径裸题】
RoadsintheNorthTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 2350 Accepted: 1152DescriptionBuildingandmaintainingroadsamongcommunitiesinthefarNorthisanexpensivebusiness.Withthisinmind,theroad
chenzhenyu123456
·
2015-08-03 12:00
暑假-动态规划 III-(A - Constructing
Roads
In JGShining's Kingdom)
/* 题意:有2n个城市,其中有n个富有的城市,n个贫穷的城市,其中富有的城市只在一种资源富有, 且富有的城市之间富有的资源都不相同,贫穷的城市只有一种资源贫穷,且各不相同, 现在给出一部分贫穷城市的需求,每个需求都是一个贫穷的向一个富有的城市要资源, 且每个富有的城市都想向贫穷的城市输入自己富有的那部分资源,现在为了运输要建设多条路, 但是路与路之间不允许有交叉,求满足贫穷城市的各种要求最多可以
slime_kirito
·
2015-08-02 11:00
动态规划
上一页
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
其他