DescriptionBessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossiblebeforeFarmerJohnwakesherforthemorningmilking.Bessieneedsherbeautysleep,soshewantstogetbackasquicklyaspossible.FarmerJohn'sfieldhasN(2<=N<=1000)landmarksinit,uniquelynumbered1..N.Landmark1isthebarn;theappletreegroveinwhichBessiestandsalldayislandmarkN.CowstravelinthefieldusingT(1<=T<=2000...
DescriptionDuetorecentrains,waterhaspooledinvariousplacesinFarmerJohn'sfield,whichisrepresentedbyarectangleofNxM(1<=N<=100;1<=M<=100)squares.Eachsquarecontainseitherwater('W')ordryland('.').FarmerJohnwouldliketofigureouthowmanypondshaveformedinhisfield.Apondisaconnectedsetofsquareswithwaterinthem,whereasquareisconsideredadjacenttoalleightofitsneighbors.GivenadiagramofFar...
Applemanhasatreewith n vertices.Someofthevertices(atleastone)arecoloredblackandotherverticesarecoloredwhite.Considerasetconsistingof k (0 ≤ k < n) edgesofAppleman'stree.IfApplemandeletestheseedgesfromthetree,thenitwillsplitinto (k + 1) parts.Note,thateachpartwillbeatreewithcoloredvertices.NowApplemanwonders,whatisthenumberofsetssplittingthetreeinsuchawaythateachresultingp...
近期评论