#K71527. Unique Permutations Count
Unique Permutations Count
Unique Permutations Count
You are given a list of words. For each word, consider the word obtained by sorting its letters in lexicographical order. Two words are considered equivalent if their sorted forms are identical.
Your task is to determine the number of unique words (based on their sorted form) that can be obtained from the list.
Formally, given a list of words \(w_1, w_2, \ldots, w_n\), let \(f(w)\) be the sorted string of \(w\). You need to compute the number of distinct values in \(\{ f(w_1), f(w_2), \ldots, f(w_n) \}\).
Example: For the input words: "abc", "bca", "dac", "cad", "xyz" the sorted forms are "abc", "abc", "acd", "acd", "xyz" respectively. There are 3 unique sorted words: "abc", "acd", "xyz".
inputFormat
The first line of the input contains a single integer \(N\) (\(1 \leq N \leq 10^5\)), representing the number of words.
The following \(N\) lines each contain a single word consisting of lowercase English letters.
outputFormat
Output a single integer: the number of unique words (based on their sorted letters).
## sample5
abc
bca
dac
cad
xyz
3