#P1827F. Copium Permutation
Copium Permutation
No submission language available for this problem.
Description
You are given a permutation of the first positive integers. A subarray is called copium if we can rearrange it so that it becomes a sequence of consecutive integers, or more formally, if For each in the range , print out the maximum number of copium subarrays of over all ways of rearranging the last elements of .
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer ().
The second line of each test case contains integers (). It is guaranteed that the given numbers form a permutation of length .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case print integers as the answers for each in the range .
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer ().
The second line of each test case contains integers (). It is guaranteed that the given numbers form a permutation of length .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case print integers as the answers for each in the range .
Note
In the first test case, the answer permutations for each are , , , , , .
In the second test case, the answer permutations for each are , , , , .