中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题Word格式.docx
《中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题Word格式.docx》由会员分享,可在线阅读,更多相关《中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题Word格式.docx(12页珍藏版)》请在冰豆网上搜索。
SampleInput
10
1000000000
SampleOutput
13
ProblemB.BigDinner
5000MSMemoryLimit:
Therewillbeabigdinnerinwincat’shome.Heisquitebusypreparingthedinner,buydifferentsizeofcircledish,vegetablesandvarymeats.Afterhehasalmostpreparedeverythingalready,differentsizesofdishwithvarydeliciousfoodsonthesquaretable.Suddenly,thepowercutout,andhehasnotfinishedthefinalstepofthepreparation—changestheplaceofsomedishtomakethebigmeallookbetter.Fortunately,wincathasalreadywrittendownallthecoordinateandradiusofeachplate.Eachtime,hecanjusttakeonedishoutandthenputitdownatanotherplaceofthetable(wecan’tletthedishoverlapandwejustneedtoputthecenterofthedishonthetable),Heassumethecoordinateofthesquaretableisatwo-dimcoordinatelikethepictureofbelow:
y
Squaretable
x
(0,0)
Althoughhehasthedata,therearetoomanydishesonthetablehecan’tdecideifthemoveofthedishislogical(thedishcan’toverlap).Youarethebestfriendofhimandalsoatalentprogrammer,couldyouhelphim?
Therewillbemultiplytests,readuntiltheendoffile.Thefirstlineofeachtestaretwointegersize(0<
size<
=500),number(1<
=k<
=100000).Sizeisthesidelengthofthesquaretable;
kisthetotalnumbersofthedishesonthetable.Followingwithklines,eachlinehasthreefloatnumberxiyiri(xiyiisthecoordinateofthedish,riistheradiusofthedish)andalsothedishisnumberedfrom0tok-1intheorderoftheinput.Nextwillbealinewithoneintegerm(0<
m<
=100000)meanstheoperationthatwincatwilldo,followingwithmlines,eachlinecontainoneintegerIDjandtwofloatnumber(xj,yj)meanstheplacewherethedishwhichisnumberedIDjwillputon.
Foreachoperationthewincatmove,tellheifhismovementislogical.IfitislogicaloutputtheIDofthedishwith”movesuccess!
”oroutputtheIDofthedishwith”movefail!
”.(ifthemoveisfail,thedishwillbeontheoriginplacewhereitis)
Outputextratwospacelineaftereachtestdata.
10103
2.502.502.48
7.502.502.48
2.507.502.48
3
02.507.50
27.507.50
0failmove!
2successmove!
0successmove!
ProblemC.LengthofArc
1000MSMemoryLimit:
100000K
Therearemanycirclesandalightspotontheplane.Allofcircledonotallowlighttogothroughthemandallofthemarenotintersect.Nowyoumusttocalculatethelengthofarewhichcanlightbythelightspot.
Input
Theinputcontainsmultipletestcases.Foreachtestcase:
Thefirstlineisanintegernumbern,indicatingthenumberofcircles,thennlinesfollowing,eachlinehasthreenumberx,y,r,indicatingthecoordinateofthecentreandradius.Thelastlineofeachtestcasecontainstwonumberindicatedthecoordinateofthelightspot.Allthenumbersinonelineareseparatedbyspaces.
Foreachtestcase,outputonelinecontaininganumberwith3digitsafterdecimalpointrepresentingtheanswerdescribingabove.
2
201
804.5
00
SampleOutput
5.713
ProblemD.Consecutive-digitNumber
TimeLimit:
1000MSMemoryLimit:
RecentlyGingerfoundthattherearemanynumbers,digitsofwhomcanberearrangedtoaconsecutivesequence.Forinstance,254310isaconsecutive-digitnumber,sincethedigitsofitare2,5,4,3,1and0,whichcanberearrangedto"
0,1,2,3,4,5"
.
Asequenceisconsecutive,ifitformsaone-ascendingdigitsequenceeitherconsecutivelyorcircularlyfrom9to0.Forexample,both"
1,2,3,4"
and"
8,9,0,1"
areconsecutivesequences.
Theinitialzerosofagivennumberareofcourseomitted.
Thereareseveralinputcases,asinglepositiveintegerinasinglelineforeachinputcase.Inputendwith0.
YESorNOinasingleline,ifthegivennumberisaconsecutive-digitnumberornot.
1423
7980
21350
2100
YES
NO
ProblemE.klongestpaths
4000MSMemoryLimit:
Inadirectedacyclicgraph(DAG),therearenverticesandmedges.Foreachedge(i,j),itsubjectstoi<
j,anditcomesfromvertexitovertexj.Thereisnotmorethanoneedgefromvertexitovertexj.Now,youshouldfindtheklongestpathsfromsourcevertextodestinationvertex.Thelengthofapathisthesumoflengthsofedgesonthepath.Youcanalwaysthinkthesourcevertexis0,andthedestinationvertexisn-1.
Therearemanydatasetintheinput.Thefirstlineineachdatasethasthreeintegernumbers.Thefirstintegernisthenumberofverticesinthegraph,thesecondonemisthenumberofedges,andthethirdisk(n<
=100000,m<
=200000andk<
=1000).Followedthefirstlinearemlines,eachofthemhasthreeintegernumbersi,j,l,whichindicatesanedgefromitojwiththelengthofl.
Thelastdatasetisfollowedbyalinecontainingthreezeros.Twoormoreinputitemsinalineareseparatedbyaspace.
Foreachdatasetintheinput,ifthenumberofdistinctpathsfrom0ton-1iskormore,youshouldoutputtheklongestpaths.First,yousortthesepathsbylengthfromlongtoshort.Iftwoormorepathsarethesamelength,youshouldsortthembyprefix.(Example:
PathA:
a1,a2,a3........as,PathB:
b1,b2,b3,.....bt,PathAandPathBhavethesamelength,thenPathAisoutputfirstifai=bi(1<
=i<
=k)anda[k+1]<
b[k+1].)Ifthenumberofdistinctpathsfrom0ton-1islessthank,youshouldoutputallpathsasabove.Ifnopathfrom0ton-1,thestring"
None"
shouldbeprinted.Eachlinecontainsonepath.Thefirstnumberisthelengthofthepath,andfollowstheverticesthatthepathtraversedfrom0ton-1.Twoormoreoutputitemsinalineareseparatedbyaspace.
Apathvisitingthesamevertextwiceormoreisnotpossible.
335
121
231
131
6710
0138
1220
2310
3460
2460
450
350
000
None
128012345
11801245
6801235
ProblemF.Robots
Communicationisanimportantcomponentforrobotsworktogether.Now,thereareNrobotsintwo-dimensionalplane.Theircoordinatesare(x1,y1),...,(xn,yn).EachrobotcancommunicatewithotherrobotsthroughwirelessinamaximumEuclideandistanceD.Theserobotscanonlycommunicatewitheachotherdirectly.Communicatingotherrobotsthroughanagentrobotisnotallowed.Theproblemiscalculatingasetofrobotswithmaximumsize,everyrobotinthesetcancommunicatewithotherrobotsinthesetdirectly.
ThefirstlineofinputisthenumbertestcaseT(T<
=100).Ttestcasesfollow.EachtestcasebeginswithalinewithtwointegersN(2<
=200)andD.Nisthenumberofrobots,Disthemaximumcommunicatedistance.ThefollowedNlinesarecoordinatesofNrobots.Eachlineistwointegers(xi,yi),thecoordinateforroboti.
Foreachtestcase,youshouldoutputalinewiththesizeofmaximumsetdescriptabove.
21
10
53
20
02
-20
0-2
ProblemG.Network
IfyouhadparticipatedinCUGPC(CUGProgrammingContest)2009or2010,youmayberememberwehadproblemstotransferdatainacomputernetwork.Thisyear,wefoundanewdifficultproblem.Thisproblemis:
Therearesomecomputersinthecomputerroom,whichareplacedinacirclewayandeverytwoneighboringcomputersareconnectedbylocalareanetwork.Eachcomputercanexchangedatawiththeneighborone.However,thesignalstrengthwouldweakenaftertransferonthenetwork.Andeverycomputercantransferdatatoallcomputers(includethecomputeritself)clockwiseoranti-clockwisearoundthecircle.Thefigurebelowshowsthefirsttestcaseofsampleinput.
Theinputconsistsofmultipletestcases.Foreachtestcase,thefirstlinecontainsaintegerN(2<
=500000),thenumberofcomputer,followedbytwolines.EachlinecontainsNintegers.Andtheithnumberofthesecondline,inincreasingorder,indicatesthedistancebetweencomputeriandcomputeri+1.TheNthdistanceindicatesthedistancebetweencomputerNandcomputeri.
Foreachtestcase,output2line.Thefirstlineisthenumberofnodescantransferdataaroundthecircleornot.Thesecondlineisidsofthesenodesinincreasingorder.
5
31505
12214
135
ProblemH.SuperFour
Lvyunisattractedbycryptographyrecently.Hewantstoinventthestrongestencryptionalgorithminthehistory.Numbertheoryisafundamentalofcryptography.Inhisalgorithm,alotofnumbertheoriesareused.However,Lvyunispoorinmath.Hewantstoaskyou,thesmartestprogrammerin