TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

The longest common subsequence problem (LCS) is finding the longest subsequence
common to all sequences in a set of sequences (often just two). It is a classic computer
science problem, the basis of diff, and has applications in bioinformatics.
Given a set of sequences, you have to pick up 3 sequences with the length of LCS of the
3 sequences is maximum.

Input Format

There are several test cases. First line of test case contains a number n (3<=n<=15),
denoting the number of sequences. Following are n sequences, each on a line. The
sequences do not contain any spaces. Each sequence has max length 100.

Output Format

For each test case, output the length of LCS of the 3 sequences that have maximum LCS
length of these sequences.

Sample Input 1

4
a
ab
abc
abcd

Sample Output 1

2

Hints

Problem Source

Migrated from old NTUJ.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 20