CF1330B.Dreamoon Likes Permutations
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 p1 and p2 of non-zero lengths l1 and l2 .
Now Dreamoon concatenates these two permutations into another sequence a of length l1+l2 . First l1 elements of a is the permutation p1 and next l2 elements of a is the permutation p2 .
You are given the sequence a , and you need to find two permutations p1 and p2 . 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.)
输入格式
The first line contains an integer t ( 1≤t≤10000 ) denoting the number of test cases in the input.
Each test case contains two lines. The first line contains one integer n ( 2≤n≤200000 ): the length of a . The second line contains n integers a1,a2,…,an ( 1≤ai≤n−1 ).
The total sum of n is less than 200000 .
输出格式
For each test case, the first line of output should contain one integer k : the number of ways to divide a into permutations p1 and p2 .
Each of the next k lines should contain two integers l1 and l2 ( 1≤l1,l2≤n,l1+l2=n ), denoting, that it is possible to divide a into two permutations of length l1 and l2 ( p1 is the first l1 elements of a , and p2 is the last l2 elements of a ). You can print solutions in any order.
输入输出样例
输入#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
输出#1
2 1 4 4 1 1 4 2 0 0 1 2 10 0
说明/提示
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.