QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#18690. Permutation Compression II

الإحصائيات

For an element in an array, if it is non-zero and it is strictly greater than all of the elements before it, then it is considered as a beautiful element. We define the beauty of an array as the number of beautiful elements in the array.

There is a permutation of length $n$. You want to maximize its beauty by changing some of the beautiful elements into zero. Note that some elements may become beautiful after your operation, and it will become available as a target of your operation.

Since modifying the array is tiring, you decide to maximize the beauty of the array by using the minimum number of operations possible.

If there are multiple solutions, output any.

Input

There are multiple test cases.

The first line contains an integer $t$ ($1 \leq t \leq 10^6$), denoting the number of test cases. For each test case:

The first line contains an integer $n$ ($1 \leq n \leq 10^6$), denoting the size of the permutation.

The next line contains $n$ integers $p_i$ ($1 \leq p_i \leq n$), denoting the elements in the permutation. It is guaranteed that all $p_i$ in one test case are distinct.

It is guaranteed that $\sum n \leq 10^6$.

Output

For each test case:

The first line contains two integers $b,c$, denoting the maximum beauty of the modified array and the minimum number of operations.

The second line contains $c$ integers $o_i$, denoting the operation sequence. Operation $o_i$ means to change the $o_i$-th element into zero. You should make sure that the $o_i$-th element is beautiful before your $i$-th operation.

If there are multiple solutions, output any.

Examples

Input 1

2
3
3 1 2
3
1 2 3

Output 1

2 1
1
3 0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.