Codeforces Round 631 (Div. 2) - Thanks, Denis aramis Shitov!
B
Dreamoon Likes Permutations
Codeforces
1400
原题
← AC →
翻译中…

The sequence of $m$ integers is called the permutation if it contains all integers from $1$ to $m$ exactly once. The number $m$ is called the length of the permutation.

翻译中…

Dreamoon has two permutations $p_1$ and $p_2$ of non-zero lengths $l_1$ and $l_2$.

翻译中…

Now Dreamoon concatenates these two permutations into another sequence $a$ of length $l_1 + l_2$. First $l_1$ elements of $a$ is the permutation $p_1$ and next $l_2$ elements of $a$ is the permutation $p_2$.

翻译中…

You are given the sequence $a$, and you need to find two permutations $p_1$ and $p_2$. If there are several possible ways to restore them, you should find all of them. (Note that it is also possible that there will be no ways.)

翻译中…

Input

翻译中…

The first line contains an integer $t$ ($1 \le t \le 10\,000$) denoting the number of test cases in the input.

翻译中…

Each test case contains two lines. The first line contains one integer $n$ ($2 \leq n \leq 200\,000$): the length of $a$. The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq n-1$).

翻译中…

The total sum of $n$ is less than $200\,000$.

翻译中…

Output

翻译中…

For each test case, the first line of output should contain one integer $k$: the number of ways to divide $a$ into permutations $p_1$ and $p_2$.

翻译中…

Each of the next $k$ lines should contain two integers $l_1$ and $l_2$ ($1 \leq l_1, l_2 \leq n, l_1 + l_2 = n$), denoting, that it is possible to divide $a$ into two permutations of length $l_1$ and $l_2$ ($p_1$ is the first $l_1$ elements of $a$, and $p_2$ is the last $l_2$ elements of $a$). You can print solutions in any order.

翻译中…

Note

翻译中…

In the first example, two possible ways to divide $a$ into permutations are $\{1\} + \{4, 3, 2, 1\}$ and $\{1,4,3,2\} + \{1\}$.

翻译中…

In the second example, the only way to divide $a$ into permutations is $\{2,4,1,3\} + \{2,1\}$.

翻译中…

In the third example, there are no possible ways.

翻译中…

样例

Input #1
6
5
1 4 3 2 1
6
2 4 1 3 2 1
4
2 1 1 3
4
1 3 3 1
12
2 1 3 4 5 6 7 8 9 1 10 2
3
1 1 1
Output #1
2
1 4
4 1
1
4 2
0
0
1
2 10
0
InputCopy OutputCopy
题目信息
题号
1330B
时间限制
2 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。