创建于 2026/07/17 · 更新于 2026/07/17
Ostad gave Nostad an array of length as a birthday gift. However, Nostad thinks that the array is not beautiful because it contains too many bad-looking subsegments.
Nostad considers a subsegment
to be bad-looking if it satisfies at least one of the following conditions:
Nostad plans to remove the elements of the array one by one until the array contains exactly one element. In each operation, he chooses one element of the current array, removes it, and then concatenates the remaining parts.
Before performing any removal and after each removal operation, Nostad computes the length of the longest bad-looking subsegment of the current array and writes it down. As a result, after the array is reduced to a single element, he obtains a sequence
where denotes the length of the longest bad-looking subsegment of the initial array, and for each , denotes the length of the longest bad-looking subsegment after the -th removal.
Since Nostad wants to make the array beautiful as fast as possible, he wants to choose the order of deletions such that the sequence is lexicographically minimum.
Your task is to compute the lexicographically minimum possible sequence .
The first line contains an integer , the number of test cases.
For each test case:
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single line containing integers
where is the lexicographically minimum sequence of longest bad-looking subsegment lengths that Nostad can obtain for that test case.
4
7
1 2 3 4 3 2 1
6
2 7 4 3 7 7
5
5 4 3 2 1
5
1 2 3 4 5
4 4 3 3 2 2 1
3 3 2 2 2 1
5 4 3 2 1
5 4 3 2 1