#K15411. Unique Anagram Count
Unique Anagram Count
Unique Anagram Count
Given a string consisting of lowercase alphabetic characters and spaces, your task is to compute the unique anagram count for each distinct word. Two words are anagrams if one can be rearranged to form the other.
For a word \(w\), its anagram count is defined as \(count = \left|\{u \in S : sorted(u) = sorted(w)\}\right|\), where \(S\) is the set of all distinct words in the input string and \(sorted(\cdot)\) denotes the letters of the word sorted in non-decreasing order.
You should output each distinct word along with its unique anagram count in lexicographical order.
inputFormat
The input is provided via standard input. It consists of a single line (or multiple lines combined) containing lowercase alphabetic characters and spaces.
outputFormat
Print to standard output: for each distinct word in the input, output a line with the word and its unique anagram count separated by a space. The lines must be sorted in lexicographical order by the word.
## samplecat act tac cat
act 3
cat 3
tac 3
</p>