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

21142번 - Longest Common Subsequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB104665571.429%

문제

You are given $n$ strings, each a permutation of the first $k$ upper-case letters of the alphabet.

String $s$ is a subsequence of string $t$ if and only if it is possible to delete some (possibly zero) characters from the string $t$ to get the string $s$.

Compute the length of the longest common subsequence of all $n$ strings.

입력

The first line of input contains two integers $n$ (1ドル \le n \le 10^5$) and $k$ (1ドル \le k \le 26$), where $n$ is the number of strings, and the strings are all permutations of the first $k$ upper-case letters of the alphabet.

Each of the next $n$ lines contains a single string $t$. It is guaranteed that every $t$ contains each of the first $k$ upper-case letters of the alphabet exactly once.

출력

Output a single integer, the length of the longest subsequence that appears in all $n$ strings.

제한

예제 입력 1

2 3
BAC
ABC

예제 출력 1

2

예제 입력 2

3 8
HGBDFCAE
ADBGHFCE
HCFGBDAE

예제 출력 2

3

예제 입력 3

6 8
AHFBGDCE
FABGCEHD
AHDGFBCE
DABHGCFE
ABCHFEDG
DGABHFCE

예제 출력 3

4

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2020 Southeast USA Regional Programming Contest I번

ICPC > Regionals > North America > Mid-Central Regional > 2020 Mid-Central Regional Programming Contest L번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 1 J번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 2 AA번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2020 Mid-Atlantic USA Regional Contest L번

ICPC > Regionals > North America > South Central USA Regional > 2020 South Central USA Regional Contest I번

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

출처

대학교 대회

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

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