아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Repeat

면접 대비

시간 제한1초메모리 제한1024 MB

요약
문자열에서 서로 겹치지 않게 두 번 이상 나타나는 가장 긴 부분 문자열을 찾아 길이와 첫 번째 형태를 출력한다.
난이도

보통10점 중 7점

유형
문자열, 이분 탐색, 문자열 매칭, 해시맵
정답자
아직 제출이 없습니다

문제

Your teacher has been marking students off on their essays for repeating words and phrases when they could be exploring new syntax and using a thesaurus to spice up their writing. In order to save yourself from being called out for using repeats, you decide to create a way to check your essay for repeated substrings and find the longest one to fix. Write a program that, given a string of characters, finds the greatest repeated substring with no overlapping characters.

입력

The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will consist of one line with a string of letters of unknown length.

출력

Output the integer length of the longest repeated substring, a space, and then the repeated string. If there are multiple with the same length, print out the first one to appear in the string.

예제1

  1. 예제 1

    입력
    2
    thequickbrownfoxjumpedoverthelazydog
    ratsarejustlikebigmicebutratsarecompletelydifferentanimals
    
    예상 출력
    3 the
    7 ratsare