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

11590번 - SAVEZ 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB3111155523.207%

문제

There are eight planets and one planetoid in the Solar system. It is not a well known fact that there is a secret planet S4 inhabited by small creatures similar to bears, their codename being Lodas. Although this fact is well hidden from the public, the association Savez sent a team lead by general Henrik to study the Lodas. It has been discovered that Lodas have the ability of teleportation and he wants to hire them in his army.

One Lod consists of N strings where the ith string is denoted by xi. Research has shown that the number of teleportations a Loda can make depends on one special subsequence (not necessarily consecutive) of these strings. Strings xi and xj (i < j) can both be in that sequence if and only if string xj both starts with and ends with string xi. The number of teleportations a Loda can make is the length of the longest described subsequence.

Determine the number of teleportations.

입력

The first line of input contains of the integer N, the number of strings. Each of the following N lines contains one string consisting of uppercase letters of the English alphabet. The input data will be such that there will be less than two million characters in total.

출력

The first and only line of output must contain the number of teleportations a Loda can make.

제한

예제 입력 1

5
A
B
AA
BBB
AAA

예제 출력 1

3

예제 입력 2

5
A
ABA
BBB
ABABA
AAAAAB

예제 출력 2

3

예제 입력 3

6
A
B
A
B
A
B

예제 출력 3

3

힌트

Clarification of the first example: Prefix and suffix can intersect so subsequence is A → AA → AAA

Clarification of the third example: Strings in the subsequence are allowed to be equal so subsequence is A → A → A or B → B → B

출처

Contest > Croatian Open Competition in Informatics > COCI 2015/2016 > Contest #2 4번

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

출처

대학교 대회

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

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