Logo
(追記) (追記ここまで)

16613번 - Bad Keming 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB96252427.273%

문제

You and your fellow teammates have just founded a startup to sell nameplates to programmers. After having carefully researched your target market, you have determined that it is best to use a monospace font.

Your very first client has asked you to print the source string S onto a nameplate. Unfortunately, you have set up your laser printer incorrectly and have accidentally printed a space before the first character, after the last character and between every character of the string.

Your client is expecting this nameplate very soon (in 5 hours, to be precise), so you do not have time to reconfigure your printer or to find a new plate. To salvage your current plate, you have decided to use the printer to fill in each space with a single character, such that the longest possible prefix of the source string S appears as a substring of your plate. A substring is a contiguous subsequence of characters.

For example, say you intended to print ENDED. Instead, your printer printed _E_N_D_E_D_ (using _ to indicate a space), which you could fill as JEJNJDJENDE. This string contains ENDE, which is a prefix of S with length 4. This is the best you can do.

As a second example, consider the string ERROR. This would be printed as _E_R_R_O_R_, which you could fill as JEJRERRORRJ. In this case, the entire source string ERROR is a substring of the final plate.

What is the length of the longest prefix of the source string that you can print on the nameplate?

입력

The input consists of a single line containing the string S. The string contains only uppercase letters and consists of at least 1 and at most 2 000 000 characters.

출력

Display the length of the longest prefix of S that you can print on the nameplate.

제한

예제 입력 1

ENDED

예제 출력 1

4

예제 입력 2

ERROR

예제 출력 2

5

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2018 ACM South Pacific Programming Contest B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /