#K85737. Maximum Length of a Unique Character Concatenation

    ID: 36708 Type: Default 1000ms 256MiB

Maximum Length of a Unique Character Concatenation

Maximum Length of a Unique Character Concatenation

You are given an array of strings. Your task is to determine the maximum length of a concatenated string that can be formed by concatenating any subset of these strings such that every letter in the resulting string is unique.

In other words, for a given subset \(S \subseteq \{s_1, s_2, \dots, s_n\}\), if you form the string \(T = s_{i_1} \oplus s_{i_2} \oplus \cdots \oplus s_{i_k}\), then every character in \(T\) must appear only once. You need to maximize \(|T|\), the length of \(T\).

Example: Given the strings "un", "iq", and "ue", one optimal concatenation is "uniq" which has a length of 4. Note that concatenating all three yields "uniqeu" but that string has repeated characters.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer \(n\) representing the number of strings.
  • The following \(n\) lines each contain a non-empty string consisting of lowercase English letters.

outputFormat

Output a single integer to standard output (stdout): the maximum length of a concatenated string that has all unique characters.

## sample
3
un
iq
ue
4