DescriptionAmusicalmelodyisrepresentedasasequenceofN(1<=N<=20000)notesthatareintegersintherange1..88,eachrepresentingakeyonthepiano.Itisunfortunatebuttruethatthisrepresentationofmelodiesignoresthenotionofmusicaltiming;but,thisprogrammingtaskisaboutnotesandnottimings.Manycomposersstructuretheirmusicaroundarepeating&qout;theme&qout;,which,beingasubsequenceofanentiremelody,isasequ...
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...
YouaregivenastringSwhichconsistsof250000lowercaselatinlettersatmost.WedefineF(x)asthemaximalnumberoftimesthatsomestringwithlengthxappearsinS.Forexampleforstring'ababa'F(3)willbe2becausethereisastring'aba'thatoccurstwice.YourtaskistooutputF(i)foreveryisothat1<=i<=|S|.InputStringSconsistsofatmost250000lowercaselatinletters.OutputOutput|S|lines.Onthei-thlineoutputF(i).Example...
近期评论