[測試] test已刪文
StringAndSubstringDescriptionYouaregivenastringsandanintegerm,yourtaskistosolvetwoproblems:Findalongeststringt,sothattisasubstringofs,andappearsatleastmtimesins.Thedefinitionofsubstringisasequenceofconsecutivecharactersinastring.Forexample,s=baaaababababbababbab,m=3,thentheanswerwouldbebabab,sincethereisnoothersubstringofsislongerthanbababandappearsatleast3timesinstrings.Findalongeststringr,suchthatrisaprefixofsandasuffixofs.Inotherwords,risthebeginningofthestringsandtheendofthestrings.Tomakeitmorechallen
ging,stringralsoneedtobeabletobelocatedsomewhereinsidethestrings,thatis,itisneitherbeginning,noritsend.Forexample,s=abcdabcabc,theanswerisabc,becauseitappearsatpositions0prefix,4neitherprefixnorsuffix,7suffix,whichmeetstherequirements.InputFormatTheinputcontainsseveraltestcases.Eachtestcaseconsistsofalinewithanintegermm
,
theminimumnumberofrepetitions,followdbyalinecontainingastrings.Allcharactersinsarelowercasecharactersfromatoz.Thelasttestcaseisdenotedbym=0andmustnotbeprocessed.OutputFormatForeachtestcase,youneedtoprinttwolinesofanswers:Forproblem1,ifthereisnosolution,outputnonewithoutthequotes;otherwise,printtwointegersinaline,separatedbyaspace.Thefirstintegerdenotesthemaximumlengthofasubstringappearingatleastmtimes;thesecondintegeristherightmostpossiblestartingpositionofsuchasubstring.Forproblem2,printthestringthatmeet
stherequirements.Ifasuitablestringdoesnotexist,thenprintJustalegendwithoutthequotes.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 112.105.152.177
※ 文章網址: https://www.ptt.cc/bbs/Test/M.1557776690.A.B2A.html
→
05/14 05:15,
6年前
, 1F
05/14 05:15, 1F
→
05/14 18:39,
6年前
, 2F
05/14 18:39, 2F
討論串 (同標題文章)