ACM杯比赛往年试题集锦.docx
《ACM杯比赛往年试题集锦.docx》由会员分享,可在线阅读,更多相关《ACM杯比赛往年试题集锦.docx(18页珍藏版)》请在冰豆网上搜索。
ACM杯比赛往年试题集锦
EscortofDr.WhoHow
TimeLimit:
2000MS
MemoryLimit:
131072K
TotalSubmissions:
1376
Accepted:
266
Description
Thenotoriousringleaderandcyber-criminalDerekWu,betterknownasDr.WhoHow,hasbeenconvictedformultipleabductionsandcyber-fraudsseveralminutesago.Hewillsoonbetransferredfromthecourttotheprisontoservealifesentence.IntelligencefromundercoverofficersinDr.WhoHow’soutlawedgangindicatesapossibleforciblerescueoperationbygangmembersinthecasethatDr.WhoHowisconvicted.Toensureasuccessfulescort,besidesadoptingenhancedsecuritymeasures,thepoliceforcefurtherdesirestominimizetheescorttime—thetimethatthemotorcadeofescorthastospendbetweendeparturefromthecourtandarrivalattheprison.
Thecomplextrafficconditioninthecityimposescomplicationsonthepoliceforce’sescorteffort.Whilethemunicipalgovernmenthasagreedtotemporarilyshutdownafewroadsforexclusivepoliceuse,theshut-downtimewindowsvaryamongroadsandaregenerallynarrowtoavoidexcessivelydisturbingthelifeofthecitizens.Themotorcadeofescortmustpassthroughanyroadentirelywithinitsshut-downtimewindowandnotuseanyroadthatthemunicipalgovernmenthasnotagreedtoshutdown.
Giveninformationaboutallroadsavailabletothepoliceforcefortheescort,determinetheshortestescorttime.
Input
Theinputcontainsasingletestcase.Thefirstlinecontainsfourintegersn,m,sandt(2≤n≤100;0≤m≤1000;1≤s,t≤n;s≠t).Therearenjunctions,somepairsofwhichareconnectedbymroads.Thecourtandtheprisonarelocatedatthes-thandthet-thjunctions,respectively.Thenextmlineseachcontainfiveintegersx,y,b,eandc(1≤x,y≤n;0≤bOutput
Iftheescortispossible,printtheshortestescorttime;otherwise,print“Impossible”.
SampleInput
4514
12011
12012
13132
24341
34341
SampleOutput
3
Hint
ThesampleisdepictedinFigure1.Eachjunctionisrepresentedbyanumberedspot.Eachroadisrepresentedbyanarrowlabeledwith
itsshut-downtimewindowandpass-throughtime.
Figure1:
Depictionofthesample
Thesecondroadlistedinthesampleisvirtuallyunusableforittakesthemotorcadeofescortlongertimetopassthroughthanitcanstayavailable.Theremainingfourroadsenablethefollowingtwoescortroutes:
1.
2.
(Thelabel
overanarrowindicatesthatthemotorcadepassesthroughthecorrespondingroadbetweentimesandt.)Thefirstroutetakesfourunitsofescorttime,whereasthesecondtakesthree,whichistheshortestpossible.
Source
PKUCampus2008(POJFounderMonthlyContest–2008.05.10),frkstyc
FullSteinerTopologies
TimeLimit:
1000MS
MemoryLimit:
131072K
TotalSubmissions:
441
Accepted:
187
SpecialJudge
Description
AfullSteinertopologyforagivenpointsetP={p1,p2,…,pn}isanundirectedtreeT=(V,E)whereV={v1,v2,…,vn,vn+1,…,v2n−2}isthesetofvertices,andEisthesetofedges.ThendistinctlylabeledleavesofT,v1,v2,…,vn,correspondtop1,p2,…,pn,respectively;theremainingn−2vertices,vn+1,vn+2,…,v2n−2,calledtheSteinervertices,aremutuallyindistinguishableandeachhaveadegreeofthree.Figure2showstheonlyfullSteinertopologyforP={p1,p2,p3}.Figure3showsallthreedifferentfullSteinertopologiesforP={p1,p2,p3,p4}.
Figure2:
FullSteinertopologyforP={p1,p2,p3}
Figure3:
FullSteinertopologiesforP={p1,p2,p3,p4}
Givenn,thecardinalityofP,computethenumberofdistinctfullSteinertopologies.
Input
Theinputcontainsmultipletestcases.Eachtestcaseconsistsofasingleintegern(3≤n≤107)onaseparateline.TheinputendswhereEOFismet.
Output
Foreachtestcase,printtheansweronaseparateline.Youshallprinttheanswerroundedtofoursignificantdigits.Letm·10ebethescientificformoftheroundedanswer,youshallprint“mEe”,givingallfoursignificantdigitsofmandstrippinganyleadingzeroesbeforee.
SampleInput
3
30
300
3000
30000
300000
3000000
SampleOutput
1.000E0
8.687E36
5.677E697
1.462E10024
1.983E130306
4.215E1603145
7.937E19031556
Source
PKUCampus2008(POJFounderMonthlyContest–2008.05.10),frkstyc
IlluminatedPlanet
TimeLimit:
1000MS
MemoryLimit:
131072K
TotalSubmissions:
198
Accepted:
45
Description
Aspaceprobeisonamissiontoobserveaplanetarysystem.Itisinstructedtoshootimagesofaplanet,whichorbitsastar,usingitso