시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 3 | 3 | 3 | 100.000% |
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.
2 3 BAC ABC
2
3 8 HGBDFCAE ADBGHFCE HCFGBDAE
3
6 8 AHFBGDCE FABGCEHD AHDGFBCE DABHGCFE ABCHFEDG DGABHFCE
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번