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
Highways
POJ 2485
Highways
#include #defineMAX_VILLAGES500 #defineINF70000 intdistanceMatrix[MAX_VILLAGES+1][MAX_VILLAGES+1]; intdistanceArray[MAX_VILLAGES+1]; intvisited[MAX_VILLAGES+1]; intmain(){ intnumOfTestcas
tiutiu2011
·
2015-10-08 13:00
最小生成树
poj
Prim
Highways
2485
POJ 2485
Highways
//题意:求最小生成树中最大边的权值 #include #include #include usingnamespacestd; #defineN505 intp[N]; intn,L; structnode { intu,v,c; }t[N*N]; intcmp(nodep,nodeq) { returnp.c
zyx520ytt
·
2015-09-09 23:00
POJ 1751
Highways
//技巧:当G++超时时,用C++,当C++超时,用G++,二者换着试试,说不定就AC了//AC代码(G++):#include #include #include usingnamespacestd; #defineN800 intp[N]; intn; intL; structnode { intx,y,w,v,c; }t[N*N],T[N*N]; intcmp(nodep,nodeq) {
zyx520ytt
·
2015-08-28 22:00
SPOJ HIGH 104
Highways
图的生成树计数 (Matrix-Tree定理)
题目大意:就是一个有n个点的无向图求不同的生成树的个数n #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include usingname
u013738743
·
2015-08-28 14:00
spoj
high
Highways
Matrix-Tree定理
POJ 2485
Highways
(最小生成树-Prim)
Description岛要修路,这个岛上有n个城市,要求修完路后,各城市之间可以相互到达,且修的总路程最短,求所修路中的最长的路段Input第一行为用例组数T,每组用例第一行为距离矩阵的行列数n,之后为一n*n矩阵表示各城市之间距离Output对于每组用例,输出总路程最短时所修路中最长的路段SampleInput13099069299001796921790SampleOutput692Solut
V5ZSQ
·
2015-08-28 09:00
POJ 2128
Highways
(水~)
Description在一条单向公路上,有n个村庄,第i个村庄只能到i以后的村庄,而不能到i之前的村庄(因为是单行道)。新村长要建两条新路,使得各个村庄之间都能走通(一条反向的就可以,为什么要建两条?题目说了,只建一条不足矣增加自己的政绩),注意,一个村庄最多修建两条铁路Input第一行为村庄个数n,第二行为n-1个整数表示n-1个村庄与第一个村庄的距离Output第一行输出两条公路的总长,第二行
V5ZSQ
·
2015-08-26 16:00
POJ 2485
Highways
A-HighwaysTimeLimit:1000MS MemoryLimit:65536KB 64bitIOFormat:%I64d&%I64uSubmitStatusDescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.Sothetrafficisdi
lizhaowei213
·
2015-08-17 15:00
POJ 2485
Highways
题目链接:http://poj.org/problem?id=2485解题思路:英语不好,果然是硬伤。。。youshouldoutputalinecontainsaninteger,whichisthelengthofthelongestroadtobebuiltsuchthatallthevillagesareconnected,andthisvalueisminimum.原来这句话的意思时求最
piaocoder
·
2015-08-15 16:00
最小生成树
POJ 1751
Highways
(最小生成树prim)
HighwaysTimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:11071 Accepted:3145 SpecialJudgeDescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasaverypoorsystemofpublichighways
zwj1452267376
·
2015-08-14 10:00
ZOJ 2048 :
Highways
【Prim】
HighwaysTimeLimit:2000/1000ms(Java/Other) MemoryLimit:20000/10000K(Java/Other)TotalSubmission(s):11 AcceptedSubmission(s):7SpecialJudgeProblemDescriptionTheislandnationofFlatopiaisperfectlyflat.Un
lin14543
·
2015-08-13 17:00
最小生成树
ZOJ
图论
Prim
1751
Highways
【最小生成树】
HighwaysTimeLimit: 1000MS MemoryLimit: 10000KTotalSubmissions: 11033 Accepted: 3127 SpecialJudgeDescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasaverypoorsystemofpublichigh
liuke19950717
·
2015-08-13 09:00
Highways
POJ 1751 【Prim || Kruscal】
DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasaverypoorsystemofpublichighways.TheFlatopiangovernmentisawareofthisproblemandhasalreadyconstructedanumberofhighwaysconnecti
yuzhiwei1995
·
2015-08-12 21:00
Highways
POJ 2485【Prim】
DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.SothetrafficisdifficultinFlatopia.TheFlatopiangovernmentisawareofthisproblem.They'replanningtobuildsomehig
yuzhiwei1995
·
2015-08-12 15:00
Highways
Poj
HighwaysTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:24872 Accepted:11468DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.SothetrafficisdifficultinF
Grit_ICPC
·
2015-08-03 16:00
最小生成树
Highways
(POJ_2485)
DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.SothetrafficisdifficultinFlatopia.TheFlatopiangovernmentisawareofthisproblem.They’replanningtobuildsomehig
highmath_Final
·
2015-07-31 09:00
poj 2485
Highways
DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.SothetrafficisdifficultinFlatopia.TheFlatopiangovernmentisawareofthisproblem.They'replanningtobuildsomehig
Code_KK
·
2015-07-30 21:00
H -
Highways
- poj 1751(prim)
某个地方政府想修建一些高速公路使他们每个乡镇都可以相同通达,不过以前已经修建过一些公路,现在要实现所有的联通,所花费的最小代价是多少?(也就是最小的修建长度),输出的是需要修的路,不过如果不需要修建就什么都不输出。 分析:构建一个完全图,使用krusal进行一些简单优化不知道可以不,试一下吧 已经T成狗了 下面是TLE的krusal代码 ***************
·
2015-07-25 10:00
Prim
Inspector's Dilemma(欧拉通路)
A road-inspector’s task is to travel through the
highways
(in either direction) and t
·
2015-07-23 17:00
inspector
poj2485
Highways
Unfortunately, Flatopia has no public
highways
. So the traffic is difficult in Flatopia.
·
2015-07-08 13:00
poj
【POJ 2485】
Highways
【POJ2485】
Highways
最小生成树模板Prim#include usingnamespacestd; intmp[501][501]; intdis[501]; boolvis[501];
ChallengerRumble
·
2015-07-03 14:00
最小生成树
【SPOJ104】【矩阵树定理】
Highways
什么?你说你看不懂英文题面?好吧其实我也看不懂…把论文里题面翻译放在英文题面下面HIGH-HighwaysnotagsInsomecountriesbuildinghighwaystakesalotoftime…Maybethat’sbecausetherearemanypossiblitiestoconstructanetworkofhighwaysandengineerscan’tmakeup
CreationAugust
·
2015-06-09 20:00
矩阵树定理
POJ2485
Highways
最小生成树的最大边
题目大意:n个村庄,给你这n个村庄之间权值的邻接矩阵,让你求出该图所生成的最小生成树的最大边。分析:和POJ1789一样,只需把纪录生成树权值的变量改成用来存放该生成树中的最大边即可。实现代码如下:#include #include #include #include usingnamespacestd; #defineINF999999999 #defineMAX505 intmap[MAX][
AC_Gibson
·
2015-04-07 11:00
UVALive 3720
Highways
组合数学
根据对称性只考虑\的斜线枚举\所在的边框的大小a,b只有在gcd(a,b)不为1的情况下才是不重复的直线有(n-a)*(m-b)个,如果边框的左上点接着一个边框的右下点则是重复的直线需要减去max(n-2*a,0)*max(m-2*b,0)个重复的边框所以对于一个边长为a,b的边框来说有 (n-a)*(m-b)- max(n-2*a,0)*max(m-2*b,0)条不同的直线最后结果*2Highw
u012797220
·
2015-02-03 16:00
poj-1751
Highways
http://poj.org/problem?id=1751最小生成树简单应用#include #include #include #include #include #include #include usingnamespacestd; #defineINF10000000 doublemap[1110][1110],dis[1110]; intn,m,v[1110],pre[1010],
u014427196
·
2015-01-27 16:00
算法
ACM
Highways
104.HighwaysProblemcode:HIGHInsomecountriesbuildinghighwaystakesalotoftime...Maybethat'sbecausetherearemanypossiblitiestoconstructanetworkofhighwaysandengineerscan'tmakeuptheirmindswhichonetochoose.Su
Guard_Mine
·
2015-01-27 13:00
POJ2485
Highways
【Prim】
HighwaysTimeLimit:1000MSMemoryLimit:65536KTotalSubmissions:23247Accepted:10720DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.SothetrafficisdifficultinFla
u011676797
·
2015-01-24 20:00
poj_2485_mst
Highways
Time Limit:1000MS Memory Limit:10000KB
·
2015-01-19 14:00
poj
UVA - 1393
Highways
(枚举包围盒大小,包围盒只有对角线穿过两个点)
#include #include #include #include usingnamespacestd; typedeflonglongLL; constintmaxn=305; intm,n; intg[maxn][maxn]; intgcd(inta,intb){ returnb==0?a:gcd(b,a%b); } voidinit(){ intlim=300; for(inti=1;i
playwfun
·
2014-12-18 13:00
Highways
求最小生成树的最大边,prime模板#include #include #include #include usingnamespacestd; intmap[1005][1005],dis[10000],mark[10000]; voidprime(intn) { for(inti=0;imap[pos][j]) dis[j]=map[pos][j]; } } cout>t; while(t--
shanyongxu
·
2014-11-06 16:00
SPOJ 104
Highways
最小生成树计数
题目链接:点击打开链接题意:给定n个点m条边的无向图,问最小生成树有几个。思路:模版#pragmacomment(linker,"/STACK:1024000000,1024000000") #include template inlineboolrd(T&ret){ charc;intsgn; if(c=getchar(),c==EOF)return0; while(c!='-'&&(c'9')
qq574857122
·
2014-10-31 11:00
poj 2485
Highways
DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.SothetrafficisdifficultinFlatopia.TheFlatopiangovernmentisawareofthisproblem.They'replanningtobuildsomehig
Misdom_Tian_Ya
·
2014-09-13 20:00
poj 1751
Highways
HighwaysTimeLimit: 1000MS MemoryLimit: 10000KTotalSubmissions: 9137 Accepted: 2548 SpecialJudgeDescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasaverypoorsystemofpublichighw
u012866104
·
2014-09-03 22:00
2433_
Highways
HighwaysTimeLimit:2SecondsMemoryLimit:65536KBSpecialJudgeInadistantcountryLinelandthereareNcitiesandtheyarealllocatedalongthehighway.Thehighwayisastraightline;itstartsfromthefirstcityandrunsthroughthe
asongsongsong
·
2014-08-25 16:00
POJ2485-
Highways
(最小生成树)
题意:给你N个城镇,用最短的距离将他们连接起来,然后M个数,每每两个代表已经有告诉公路了。思路:只要将那个已经有公路的两个城镇之间的距离当做0就行了,然后用最小生成树开始解决这一题。开始用Prim()算法,发现保存不了最小生成树的组成成员。然后用了克鲁斯卡尔算法。还有题目要求输出来的答案不一定要按照那个顺序呢。#include #include #include #include #include
KJBU2
·
2014-08-22 15:00
UVA - 1393
Highways
DescriptionHackerlandisahappydemocraticcountrywithm×ncities,arrangedinarectangularmbyngridandconnectedbymroadsintheeast-westdirectionandnroadsinthenorth-southdirection.Bypublicdemand,thisorthogonalroa
u011345136
·
2014-08-20 21:00
poj 2128
Highways
真是一道坑爹的题目,题目其实说的不是很清晰。。。WA了2次。。。[题意]在一条单向公路上,有n个村庄,第i个村庄只能到i以后的村庄,而不能到i之前的村庄(因为是单行道)。新村长要建两条新路,使得各个村庄之间都能走通(一条反向的就可以,为什么要建两条?题目说了,只建一条不足矣增加自己的政绩)[思路]找出所有路段中最短的,加上原来的总长,就是答案。有一点要注意,题目说两条路的4个端点必须不同,因此要排
Scythe666
·
2014-08-11 16:00
poj 2485
Highways
(最小生成树,prim)
小记:求最小生成树里最大的边,思路:在之前求和的基础上,将和改成判断保存最大的那条边即可。代码:#include #include #include #include #include #include #include #include #include #include #include #include usingnamespacestd; #definemst(a,b)memset(a
ljd4305
·
2014-07-30 16:00
POJ 2485
Highways
最小生成树
Prim小练习2题目大意:有n个农场,给出一个n*n的矩阵,第i行j列代表农场i到农场j的距离求一个最小生成树连接所有农场,输出最小生成树中最大的边的边权值(由于本身最小生成树选取的边就满足了尽量使得使用的边的边权值小(从Kruskal的边的排序中明显看出))很简单的最小生成树问题两种算法做法如下:Kruskal算法:Result : Accepted Memory : 500KB Time
u013738743
·
2014-07-17 12:00
poj
kruskal
Prim
Highways
2485
POJ 2485:
Highways
:典型prim最小生成树(2)
HighwaysTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 21456 Accepted: 9884DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.Sothetrafficisdifficult
smileyk
·
2014-07-16 18:00
POJ2485——
Highways
(最小生成树)
Kruskal算法#include #include #include #include usingnamespacestd; constintMAX=510; constintA=MAX*MAX/2; intans; structnode { intu,v,w; }e[A]; intf[MAX]; intfind(intx) { returnf[x]==x?x:f[x]=find(f[x]);
u014141559
·
2014-07-09 01:00
poj 1751
Highways
(水最小生成树)
O- HighwaysTimeLimit:1000MS MemoryLimit:10000KB 64bitIOFormat:%I64d&%I64uSubmit StatusDescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasaverypoorsystemofpublichighwa
u014569598
·
2014-07-08 14:00
poj2485--
Highways
HighwaysTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 21089 Accepted: 9737DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.Sothetrafficisdifficult
u013015642
·
2014-06-05 21:00
ACM-最小生成树之
Highways
——poj2485
*******************************************转载请注明出处:http://blog.csdn.net/lttree**********************************************HighwaysTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 21061 Accepte
lx417147512
·
2014-05-26 16:00
最小生成树
ACM
Prim
Highways
poj2485
[ACM] poj 2485
Highways
(最小生成树)
HighwaysTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 21056 Accepted: 9723DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.Sothetrafficisdifficult
sr19930829
·
2014-05-26 15:00
最小生成树
ACM
uva 1393 -
Highways
(容斥原理)
题目连接:uva1393-
Highways
题目大意:给定一个m∗n的矩阵,将矩阵上的点两两相连,问有多少条直线至少经过两点。解题思路:头一次做这种题目,卡了一晚上。
u011328934
·
2014-05-24 10:00
ZOJ 2048
highways
题目比我想象地要容易很多。。一开始想得太复杂了,本来想试一下kruskal算法的,嫌麻烦。。还是用了之前1203的prim算法。。。以为要注意这道题的输出顺序,结果不用,直接输出就可以了,就是注意一下空行的输出就行了//#include"stdafx.h" #include #include"stdio.h" #include usingnamespacestd; inttown[750][2];
chen_xinjia
·
2014-05-10 13:00
算法
ZOJ
UVa:1393
Highways
这个题思路是学习了别人的。我一直都是从点的角度考虑的,完全没有想到要枚举矩形。关键的思路:a与b互质且没有任何一点与a的横坐标之差和纵坐标之差都是b的两倍。另外把gcd打成了表,否则会超时。#include #include #include #include #include #definelllonglong #defineINF2139062143 #defineMAXN100
kkkwjx
·
2014-01-28 14:00
计数
数学
POJ 2485
Highways
prim最小生成树里的最长边HighwaysTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 19843 Accepted: 9201DescriptionTheislandnationofFlatopiaisperfectlyflat.Unfortunately,Flatopiahasnopublichighways.Sothetraf
u012797220
·
2014-01-21 15:00
poj
POJ 1751
Highways
(ZOJ 2048 ) MST
http://poj.org/problem?id=1751http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2048题目大意:给你n个点的坐标,并且m个点之间已经建立起连接,让你输出剩下的MST的连接点。两题其实一样。就输入一点点不同。因为题目采用SpecialJudge故水题一题。POJ:#include #include
murmured
·
2013-12-17 00:00
ACM
ZOJ
poj
MST
POJ 1258 Agri-Net|| POJ 2485
Highways
MST
POJ1258Agri-Nethttp://poj.org/problem?id=1258水题。题目就是让你求MST,连矩阵都给你了。prim版#include constintMAXN=101; constintINF=100000+10; intmap[MAXN][MAXN]; intdis[MAXN]; intn; voidprim() { boolvis[MAXN]={0}; for(i
murmured
·
2013-12-15 12:00
数据结构
ACM
poj
MST
上一页
1
2
3
4
5
下一页
按字母分类:
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
其他