DescriptionDuetorecentrains,waterhaspooledinvariousplacesinFarmerJohn'sfield,whichisrepresentedbyarectangleofNxM(1<=N<=100;1<=M<=100)squares.Eachsquarecontainseitherwater('W')ordryland('.').FarmerJohnwouldliketofigureouthowmanypondshaveformedinhisfield.Apondisaconnectedsetofsquareswithwaterinthem,whereasquareisconsideredadjacenttoalleightofitsneighbors.GivenadiagramofFar...
DescriptionFarmerJohnhasabalanceforweighingthecows.HealsohasasetofN(1<=N<=1000)weightswithknownmasses(allofwhichfitin31bits)foruseononesideofthebalance.Heplacesacowononesideofthebalanceandthenaddsweightstotheothersideuntiltheybalance.(FJcannotputweightsonthesamesideofthebalanceasthecow,becausecowstendtokickweightsinhisfacewhenevertheycan.)Thebalancehasamaximummassratingandwillbreak...
DescriptionFJandhiscowsenjoyplayingamentalgame.Theywritedownthenumbersfrom1toN(1<=N<=10)inacertainorderandthensumadjacentnumberstoproduceanewlistwithonefewernumber.Theyrepeatthisuntilonlyasinglenumberisleft.Forexample,oneinstanceofthegame(whenN=4)mightgolikethis:31244367916BehindFJ'sback,thecowshavestartedplayingamoredifficultgame,inwhichtheytrytodeterminethestartingsequencefromo...
DescriptionThefarmhasmanyhillsuponwhichFarmerJohnwouldliketoplaceguardstoensurethesafetyofhisvaluablemilk-cows.Hewondershowmanyguardshewillneedifhewishestoputoneontopofeachhill.Hehasamapsuppliedasamatrixofintegers;thematrixhasN(1<N<=700)rowsandM(1<M<=700)columns.EachmemberofthematrixisanaltitudeH_ij(0<=H_ij<=10,000).Helphimdeterminethenumberofhilltopsonthemap.Ahill...
Manystudentsliveinadormitory.Adormitoryisawholenewworldoffunnyamusementsandpossibilitiesbutitdoeshaveitsdrawbacks.Thereisonlyoneshowerandtherearemultiplestudentswhowishtohaveashowerinthemorning.That'swhyeverymorningthereisalineoffivepeopleinfrontofthedormitoryshowerdoor.Assoonastheshoweropens,thefirstpersonfromthelineenterstheshower.Afterawhilethefirstpersonleavestheshowerandthenextpersonent...
TheemployeesoftheR1companyoftenspendtimetogether:theywatchfootball,theygocamping,theysolvecontests.So,it'snobigdealthatsometimessomeonepaysforsomeoneelse.Todayisthedayofgivingoutmoneyrewards.TheR1companyCEOwillinviteemployeesintohisofficeonebyone,rewardingeachoneforthehardworkthismonth.TheCEOknowswhoowesmoneytowhom.Andhealsounderstandsthatifheinvitesperson x tohisofficeforareward,a...
近期评论