DescriptionGordistrainingforamarathon.Behindhishouseisaparkwithalargenetworkofjoggingtrailsconnectingwaterstations.Gordwantstofindtheshortestjoggingroutethattravelsalongeverytrailatleastonce.InputInputconsistsofseveraltestcases.Thefirstlineofinputforeachcasecontainstwopositiveintegers:n<=15,thenumberofwaterstations,andm<1000,thenumberoftrails.Foreachtrail,thereisonesubsequentlineofin...
Afterthesuccessof2ndanniversary(takealookatproblemFTOURformoredetails),this3rdyear,TravelAgentSPOJgoesonwithanotherdiscounttour.ThetourwillbeheldonICPCisland,amiraculousoneonthePacificOcean.WelistNplaces(indexedfrom1toN)wherethevisitorscanhaveatrip.Eachroadconnectingthemhasaninterestvalue,andthisvaluecanbenegative(ifthereisnothinginterestingtoviewthere).Simply,theseNplaces...
Celebratingthenewyear,manypeoplepostvideosoffallingdominoes;Here'salistofthem:https://www.youtube.com/results?search_query=New+Years+DominosUserainta,wholivesina2Dworld,isgoingtopostavideoaswell.Therearendominoesona2DCartesianplane.i-thdomino(1 ≤ i ≤ n)canberepresentedasalinesegmentwhichisparalleltothey-axisandwhoselengthisli.Thelowerpointofthedominoisonthex-axis.Let'sdenotethex-...
Useraintahasapermutationp1, p2, ..., pn.AstheNewYeariscoming,hewantstomakehispermutationasprettyaspossible.Permutationa1, a2, ..., anisprettierthanpermutationb1, b2, ..., bn,ifandonlyifthereexistsanintegerk(1 ≤ k ≤ n)wherea1 = b1, a2 = b2, ..., ak - 1 = bk - 1andak < bkallholds.Asknown,permutationpissosensitivethatitcouldbeonlymodifiedbyswappingtwodistinctele...
DescriptionThecityexecutiveboardinLundwantstoconstructasightseeingtourbybusinLund,sothattouristscanseeeverycornerofthebeautifulcity.Theywanttoconstructthetoursothateverystreetinthecityisvisitedexactlyonce.Thebusshouldalsostartandendatthesamejunction.Asinanycity,thestreetsareeitherone-wayortwo-way,trafficrulesthatmustbeobeyedbythetourbus.Helptheexecutiveboardanddetermineifit'spossibletocons...
Givenaweighteddirectedgraph,wedefinetheshortestpathasthepathwhohasthesmallestlengthamongallthepathconnectingthesourcevertextothetargetvertex.Andiftwopathissaidtobenon-overlapping,itmeansthatthetwopathhasnocommonedge.So,givenaweighteddirectedgraph,asourcevertexandatargetvertex,weareinterestedinhowmanynon-overlappingshortestpathcouldwefindoutatmost.InputInputconsistsofmultipletestcases.Thefirs...
DescriptionMirkoworksonapigfarmthatconsistsofMlockedpig-housesandMirkocan'tunlockanypighousebecausehedoesn'thavethekeys.Customerscometothefarmoneafteranother.Eachofthemhaskeystosomepig-housesandwantstobuyacertainnumberofpigs.AlldataconcerningcustomersplanningtovisitthefarmonthatparticulardayareavailabletoMirkoearlyinthemorningsothathecanmakeasales-planinordertomaximizethenumberofpigssold.M...
近期评论