#C2354. Disjoint Character Partition

    ID: 45661 Type: Default 1000ms 256MiB

Disjoint Character Partition

Disjoint Character Partition

You are given a list of n strings. Your task is to determine if the given strings can be partitioned into two subsets such that the union of characters in one subset does not intersect with the union of characters in the other subset. In other words, each character (from the lowercase English alphabet) should appear in at most one string. Formally, let (S_1,S_2,\dots,S_n) be the given strings. The partition is valid if for every character (c), there is at most one string (S_i) such that (c \in S_i). If such a partition exists, output "YES"; otherwise, output "NO".

Note: The partition itself is not required to have both subsets non-empty. It is sufficient that no letter appears in more than one string.

inputFormat

Input is read from standard input. The first line contains an integer (n) ((1 \le n \le 10^5)), the number of strings. Each of the next (n) lines contains a non-empty string consisting only of lowercase English letters.

outputFormat

Output a single line to standard output: "YES" if no character is shared among different strings, thus allowing a valid partition; otherwise, output "NO".## sample

3
abc
def
xy
YES

</p>