B. Divine Array
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Black is gifted with a Divine array a consisting of n (1≤n≤2000) integers. Each position in a has an initial value. After shouting a curse over the array, it becomes angry and starts an unstoppable transformation.
The transformation consists of infinite steps. Array a changes at the i-th step in the following way: for every position j, aj becomes equal to the number of occurrences of aj in a before starting this step.
Here is an example to help you understand the process better:
Initial array: 2 1 1 4 3 1 2
After the 1-st step: 2 3 3 1 1 3 2
After the 2-nd step: 2 3 3 2 2 3 2
After the 3-rd step: 4 3 3 4 4 3 4
… …
In the initial array, we had two 2-s, three 1-s, only one 4 and only one 3, so after the first step, each element became equal to the number of its occurrences in the in