#C6079. Longest Common Subset Subsequence Length
Longest Common Subset Subsequence Length
Longest Common Subset Subsequence Length
Given n sequences, your task is to find the length of the longest common subset subsequence. In other words, for each character c, let (F_i(c)) denote its frequency in the i-th sequence, then the result is given by the formula: [ \sum_{c \in \bigcap_{i=1}^{n} S_i} \min_{1 \leq i \leq n} F_i(c)] This sum represents the maximum number of characters you can collect such that each character is present in every sequence with at least the minimum frequency across all sequences. The input guarantees that the sequences contain only ASCII characters.
inputFormat
The input is read from standard input (stdin). The first line contains an integer n representing the number of sequences. Each of the next n lines contains a non-empty string representing a sequence.
outputFormat
Output a single integer to standard output (stdout) representing the length of the longest common subset subsequence formed by the common characters (with their minimum frequencies) found in every sequence.## sample
3
abc
abcd
abdc
3
</p>