The 4th ACMICPC Liaoning Province CPC Online Contest.docx
《The 4th ACMICPC Liaoning Province CPC Online Contest.docx》由会员分享,可在线阅读,更多相关《The 4th ACMICPC Liaoning Province CPC Online Contest.docx(14页珍藏版)》请在冰豆网上搜索。
The4thACMICPCLiaoningProvinceCPCOnlineContest
The4thACM-ICPCLiaoningProvinceCPCOnlineContest
<1>Virusdetection
TimeLimit:
1SecondMemoryLimit:
64Megabyte
Totalsubmit:
0Accepted:
0
Description
Oneday,apowerfulcomputervirusHinfectedcomputersallovertheworld.Ifwedon’tdeletethefileswhichareinfectedbyvirusH,thecomputerwillnotwork.
ThescientistsareworkingontheprojectthathowtodeterminewhetherafileisinfectedbyvirusH.Oneday,Dr.Dannouncesthathehasfoundaway.
“Asweallknow,inthecomputer,alldataisstoredinbinarycode.“Dr.Dsays,“Ifafile’sbinarycodestringcontainsnoneofntypesof3-bitbinarysub-string,thenwecanbesurethefileisinfectedwithHvirus.”
Well,giventhelengthofabinaryfile,andthentypesof3-bitbinarysub-string,wewanttoknowthenumberofformsoffileswhichareinfectedwithHvirus.Sincetheanswermaybequitelarge,youhavetomoduleitby100007
Input
Theinputcontainsseveraltestcases.
Eachcasestartswithtwointegersnandm,0<=n<=8,0Thefollowinglinecontainsn3-bitbinarystring.
Eachofthenextmlinescontainsaninteger,whichisthelengthofabinaryfileandwillnotexceed10000.
Output
Foreachlengthofthefile,OutputthenumberofformsoffileswhichareinfectedwithHvirusinoneline.
SampleInput
11
100
10
22
100101
10
20
SampleOutput
232
20
40
Source
***********************************************************
<2>Popkart
TimeLimit:
1SecondMemoryLimit:
64Megabyte
Totalsubmit:
0Accepted:
0
Description
Popkartisapopularonlinegame.Playerscanenjoythrillofspeedracingverymuch.
Oneday,Popkartupdatethe“GoldCollection”mode.Therulesof“GoldCollection”modeareasfollows:
Themapofthegameisann*mgrids,theeachgridinthemapareeithergroundorobstacle.Inthemap,thegroundisa‘.’,theobstacleisa‘*’.
Duringeachunitoftime,youcandothefollowingoperation:
IftheKartwasmovinginthelasttime,playercanlettheKartstopinthecurrentgird,ormovetotheleftgird,ormovetotherightgrid(relativetothecurrentorientationoftheKart).IftheplayerlettheKartmove,theKarts’directionismodifiedtothedirectionthattheKartmoves.IftheplayerlettheKartmoveleftormoveright.TheKartwilldoadrift.Inthiscasetheplayergetsaunitofn2o.
IftheKartwasstopinthelasttime,playercanlettheKartmoveforward,orletKartstopinthecurrentgird,ormovetotheleftgrid,ormovetotherightgird,ormovetothebackgird.TheKarts’directionismodifiedtothedirectionthattheKartmovesatthesametime.
Iftheplayercollect4unitofn2o(playercan’tcollectmorethan4unitofn2o),hecanchoosetolaunchtheaccelerator.Iftheplayerlaunchestheaccelerator,hewilluseoutofallthe4unitofn2o.Inthiscase,theKartcanmoveoneextragridinthesamedirectionateachunittime.Thiseffectlastsfor4units’time.Duringthistime,theKartcanonlymove2gridorstopinthecurrentgrid.Also,duringthistime,theKartwillalsogain1unitofn2oiftheKartmoveleftormoveright.
Theobstaclesonthemapcannotbepassed.IftheKartmovestothegridofobstacle,theplayerwillbedisqualified.
Atthebeginningofthegame,ThePlayer’sKartandexactonegoldwillappearintheground,markedwith‘P’and‘G’.Theplayer’skartwillstopat‘P’.Thesystemwillpromptatimet.Iftheplayercan’treachthegirdofthegoldinthetimet,theplayerwillbedisqualified.
Xiaomingisveryinterestedinthe“GoldCollection”modethathedesignsalotofmission.Hewonderswhetherthemissionhedesignedcanbefinishedintime.Ifitcan,whatistheminimumtime?
Input
TheinputstartswithonelinecontainingasingleintegerC,0EachcasestartswiththreeintegersN,MandT(2≤N,M≤100,0ThenextNlines.EachlinecontainsastringwhichlengthsisM.Whichrepresentthemapofthegame.
Output
Outputtheminimumtimetheplayerwouldspendtoreachthegridofthegold.
Iftheplayercan’treachthegirdofthegoldinthetimeT.Outputaline“-1”.
SampleInput
1
5101000
P.........
..........
..........
........**
.........G
SampleOutput
9
Hint
Ifthekartisstop,movementwillnotgainn2onomatterthedirection.
Source
********************************************************
<3>Transferwater
limeLimit:
1SecondMemoryLimit:
64Megabyte
Totalsubmit:
0Accepted:
0
Description
Greeprylivesinavillage.Lastyearfloodrainedthevillage.Sotheydecidetomovethewholevillagetothemountainnearbythisyear.Thereisnospringinthemountain,soeachhouseholdcouldonlydigawellorbuildawaterlinefromotherhousehold.Ifthehouseholddecidetodigawell,themoneyforthewellistheheightoftheirhousemultipliesXdollarpermeter.Ifthehouseholddecidetobuildawaterlinefromotherhousehold,theheightofwhichsupplywatermustbehigherthantheonewhichgetwater.ThemoneyofonewaterlineistheManhattandistanceofthetwohouseholdmultipliesYdollarpermeter.Nowgiventhe3-dimensionalposition(a,b,c)ofeveryhouseholdthecofwhichmeansheight,canyoucalculatetheminimalmoneythewholevillageneedsothateveryhouseholdhaswater.
Input
Multiplecases.
Firstlineofeachcasecontains3integersn(1<=n<=1000),thenumberofthehouseholds,X(1<=X<=1000),Y(1<=Y<=1000).
Eachofthenextnlinescontains3integersa,b,cmeansthepositionofthei-thhouseholds,noneofthemwillexceeded1000.
Ifn=X=Y=0,theinputends,andnooutputforthat.
Output
Oneintegerforeachcase,theminimalmoneythewholevillageneedsothateveryhouseholdhaswater.
SampleInput
1100100
1310
000
SampleOutput
1000
Hint
In3-dimensionalspaceManhattandistanceofpointA(x1,y1,z1)andB(x2,y2,z2)is|x2-x1|+|y2-y1|+|z2-z1|.
Source
********************************************************
<4>Theclock
TimeLimit:
1SecondMemoryLimit:
64Megabyte
Totalsubmit:
0Accepted:
0
Description
Thereisaclockshowsthetimelikethepicturebelow.Somenumberwillbealsoanumberwhenupsidedown.Forexample9,willbe6whenupsidedown.Ifthetimeis06:
09,whenupsidedownwillbe60:
90,whichisclearlynotavalidtime.Thevalidtimemustbebetween00:
00and23:
59.Nowgivenatimeintheformatofhh:
mm,pleasetellwhetherit’savalidtimewhenupsidedown?
Input
Multiplecases.
Onelineforeachcase,astringintheformatofhh:
mm
Output
Foreachcase,output“Yes”ifthestringisatimewhenlooksupsidedownor“No”ifnot.
SampleInput
90:
00
02:
20
04:
40
15:
43
SampleOutput
Yes
Yes
No
No
Hint
Source
*********************************************************
<5>OrganizationofACM/LCPC
TimeLimit:
1SecondMemoryLimit:
64Megabyte
Totalsubmit:
0Accepted:
0
Description
OrganizationofACM/ICPCisahardwork.
AfterholdingACM/DCPC(DisshortforDalian),organizersofDLMUfoundthat,it'sreallynotaneasyjobtoholdthecontest,nowtheyaregoingtoholdtheACM/LCPC(LisshortofLiaoning)andwanttoholdanevenmoresuccessfulcontest,theyknowACM/ICPChasanunwrittenruleasthat:
1.Alloftheteamssolveatleastoneproblem.
2.Thechampionsolvesatleastacertainnumberofproblems.
Nowtheorganizerhasstudiedoutthecontestproblems,andthroughtheresultofpreliminarycontest,theorganizercanestimatetheprobabilitythatacertainteamcansuccessfullysolveacertainproblem.
GiventhenumberofcontestproblemsM,thenumberofteamsT,andthenumberofproblemsNthatweexpectthechampionsolveatleast.AndtheprobabilityteamisolvesproblemjisstoredasPij(1<=i<=T,1<=j<=M).Well,canyoucalculatetheprobabilitythatalloftheteamssolveatleastoneproblem,andatthesametimethechampionteamsolvesatleastNproblems?
Input
Theinputconsistsofseveraltestcases.ThefirstlineofeachtestcasecontainsthreeintegersM(0Output
Foreachtestcase,pleaseoutputtheanswerinaseparateline.Theresultshouldberoundedtothreedigitsafterthedecimalpoint.
SampleInput
222
0.90.9
10.9
000
SampleOutput
0.972
Hint
Source
*********************************************************
<6>AtripatKingdomsofDiscovery
TimeLimit:
1SecondMemoryLimit:
64Megabyte
Totalsubmit:
0Accepted:
0
Description
BecauseofthegoodresultofACM/DCPC(DisshortforDalian),thecoachofDLMUdecidestodrivetheACMerstoKingdomsofDiscovery.TheACMersofissuresohappyaboutthis,sotheywanttohaveaniceday.
Fortunately,theyhaveadetailedmapofKingdomsofDiscoveryshowingtheL(2<=L<=1000)majorsightseeingspot(convenientlynumbered1..L)andtheP(2<=P<=5000)unidirectionalpathsthatjointhem.TheteacherwilldriveACMerstoastartingspotoftheirchoice,fromwhichtheywillwalkalongthepathstoaseriesofothersightseeingspot,endingbackattheirstartingsightseeingspotwheretheteacherwillpickthemupandtakethembacktoDLMU.BecausespaceinKingdomsofDiscoveryisatapremium,pathsareverynarrowandsotravelalongeachpathisonlyallowedinonefixeddirection.
WhileACMersmayspendasmuchtimeastheylikeinKingdomsofDiscovery,theydotendtogetboredeasily.Visiting