DescriptionThereisatravelagencyinAdeltontownonZanzibarisland.Ithasdecidedtoofferitsclients,besidesmanyotherattractions,sightseeingthetown.Toearnasmuchaspossiblefromthisattraction,theagencyhasacceptedashrewddecision:itisnecessarytofindtheshortestroutewhichbeginsandendsatthesameplace.Yourtaskistowriteaprogramwhichfindssucharoute.InthetownthereareNcrossingpointsnumberedfrom1toNandMtwo-wayr...
DescriptionAstudentnamedRoundSquarelovedtoplaywithcones.Hewouldarrangeconeswithdifferentbaseradiiarbitrarilyonthefloorandwouldadmiretheintrinsicbeautyofthearrangement.Thestudentevenbegantheorizingabouthowsomeconesdominateothercones:aconeAdominatesanotherconeBwhenconeBiscompletelywithintheconeA.Furthermore,henotedthattherearesomeconesthatnotonlydominateothers,butarethemselvesdominated,th...
LittleDaniellovestoplaywithstrings!Healwaysfindsdifferentwaystohavefunwithstrings!Knowingthat,hisfriendKinandecidedtotesthisskillssohegavehimastringSandaskedhimQquestionsoftheform:IfalldistinctsubstringsofstringSweresortedlexicographically,whichonewillbetheK-thsmallest?AfterknowingthehugenumberofquestionsKinanwillask,Danielfiguredoutthathecan'tdothisalone.Daniel,ofcourse,knowsyourexc...
Astringisfinitesequenceofcharactersoveranon-emptyfinitesetΣ.Inthisproblem,Σisthesetoflowercaseletters.Substring,alsocalledfactor,isaconsecutivesequenceofcharactersoccurrencesatleastonceinastring.Nowyourtaskisabitharder,forsomegivenstrings,findthelengthofthelongestcommonsubstringofthem.Herecommonsubstringmeansasubstringoftwoormorestrings.InputTheinputcontainsatmost10lines,eachlineconsistso...
LittleXhasndistinctintegers:p1, p2, ..., pn.HewantstodivideallofthemintotwosetsAandB.Thefollowingtwoconditionsmustbesatisfied:IfnumberxbelongstosetA,thennumbera - xmustalsobelongtosetA.IfnumberxbelongstosetB,thennumberb - xmustalsobelongtosetB.HelpLittleXdividethenumbersintotwosetsordeterminethatit'simpossible.InputThefirstlinecontainsthreespace-separatedintegersn, a, b(1...
近期评论