[測試] test已刪文
StringAndSubstringDescriptionYouaregivenastringsandanintegerm,yourtaskistosolvetwoproblems:Findalongeststringt,sothattisasubstringofs,andappearsatleastmtimesins.Thedefinitionofsubstringisasequenceofconsecutivecharactersinastring.Forexample,s=baaaababababbababbab,m3,thentheanswerwouldbebabab,sincethereisnoothersubstringofsislongerthanbababandappearsatleast3timesinstrings.Findalongeststringr,suchthatrisaprefixofsandasuffixofs.Inotherwords,risthebeginningofthestringsandtheendofthestrings.Tomakeitmorechalleng
ing,stringralsoneedtobeabletobelocatedsomewhereinsidethestrings,thatis,itisneitherbeginning,noritsend.Forexample,s=abcdabcabc,theanswerisabc,becauseitappearsatpositions0prefix,4neitherprefixnorsuffix,7suffix,whichmeetstherequirements.InputFormatTheinputcontainsseveraltestcases.Eachtestcaseconsistsofalinewithanintegermm1,theminimumnumberofrepetitions,followdbyalinecontainingastrings.Allcharactersinsarelowercasecharactersfromatoz.Thelasttestcaseisdenotedbym0andmustnotbeprocessed.OutputFormatForeachtestcase,
youneedtoprinttwolinesofanswers:Forproblem1,ifthereisnosolution,outputnonewithoutthequotes;otherwise,printtwointegersinaline,separatedbyaspace.Thefirstintegerdenotesthemaximumlengthofasubstringappearingatleastmtimes;thesecondintegeristherightmostpossiblestartingpositionofsuchasubstring.Forproblem2,printthestringthatmeetstherequirements.Ifasuitablestringdoesnotexist,thenprintJustalegendwithoutthequotes.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.204.25.70
※ 文章網址: https://www.ptt.cc/bbs/Test/M.1557821913.A.FAA.html
討論串 (同標題文章)