#K34862. Count Unique Rearranged Numbers

    ID: 25404 Type: Default 1000ms 256MiB

Count Unique Rearranged Numbers

Count Unique Rearranged Numbers

You are given a list of integers. For each integer, consider the sorted sequence of its digits. Two numbers are considered equivalent if, after sorting their digits in non-decreasing order, they result in the same sequence.

Your task is to determine the number of unique groups formed by these sorted digit sequences.

More formally, for an integer n, let \(f(n) = \text{sorted}(\text{str}(n))\). You need to compute the number of distinct values \(f(n)\) in the given list.

inputFormat

The input is given from stdin and consists of two lines:

  • The first line contains an integer n, representing the number of integers.
  • The second line contains n space-separated integers.

outputFormat

Output a single integer to stdout: the number of unique groups formed by rearranging each number's digits (i.e. by sorting the digits).

## sample
3
123 456 231
2

</p>