RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00426

Rima

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

1 \(s / 256\) \(MB / 140\) points

Little Adrian is a fan of rhyme. He believes that two words rhyme if and only if their longest
common suffix is as long as the longer of the two words, or shorter than the longer word by
1. In other words, \(A\)

and \(B\)

rhyme if and only if it holds
.
\(CS\)(\(A\), \(B\))
\(ax\)(|\(A\)|, |\(B\)|)
1
\(L\)

\(m\)

One day, while reading a collection of short stories, he decided to compose the longest
possible sequence of words such that each two consecutive words rhyme. Each word from
the sequence can appear only once.

Adrian has grown tired of this task, so he decided to go back to reading, and is asking you to
solve this task instead of him.

제약

In test cases worth 30% of points, it will hold \(N \le 18\).

입력 형식

The first line of input contains the integer \(N\)

(1 ≤ \(N\)

≤ 500 000).
Each of the following \(N\)

lines contains one word consisting of lowercase letters of the English
alphabet. All words are mutually distinct, and their total length is at most 3 000 000.

출력 형식

You must output the length of the longest sequence.

예제 1
입력
4
honi
toni
oni
ovi

5
ask
psk
krafna
sk
k

5
pas
kompas
stas
s
nemarime
출력
output
output
3

4

1
설명

Clarification of the second test case:
The only possible sequence is ask-psk-sk-k

.

Clarification of the third test case:
No two words rhyme.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2016/2017 Contest 4

평가 및 의견

Rima

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Rima

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8