CF1935B.Informatics in MAC

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the Master's Assistance Center, Nyam-Nyam was given a homework assignment in informatics.

There is an array aa of length nn , and you want to divide it into k>1k > 1 subsegments ^{\dagger} in such a way that the MEX\operatorname{MEX} ^{\ddagger} on each subsegment is equal to the same integer.

Help Nyam-Nyam find any suitable division, or determine that it does not exist.

^{\dagger} A division of an array into kk subsegments is defined as kk pairs of integers (l1,r1),(l2,r2),,(lk,rk)(l_1, r_1), (l_2, r_2), \ldots, (l_k, r_k) such that liril_i \le r_i and for each 1jk11 \le j \le k - 1 , lj+1=rj+1l_{j + 1} = r_j + 1 , and also l1=1l_1 = 1 and rk=nr_k = n . These pairs represent the subsegments themselves.

MEX^{\ddagger}\operatorname{MEX} of an array is the smallest non-negative integer that does not belong to the array.

For example:

  • MEX\operatorname{MEX} of the array [2,2,1][2, 2, 1] is 00 , because 00 does not belong to the array.
  • MEX\operatorname{MEX} of the array [3,1,0,1][3, 1, 0, 1] is 22 , because 00 and 11 belong to the array, but 22 does not.
  • MEX\operatorname{MEX} of the array [0,3,1,2][0, 3, 1, 2] is 44 , because 00 , 11 , 22 , and 33 belong to the array, but 44 does not.

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt ( 1t1041 \leq t \leq 10^4 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn ( 2n1052 \le n \le 10^5 ) — the length of the array aa .

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai<n0 \le a_i < n ) — the elements of the array aa .

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5 .

输出格式

For each test case, output a single integer 1-1 if a suitable division does not exist.

Otherwise, on the first line, output an integer kk ( 2kn2 \le k \le n ) — the number of subsegments in the division.

Then output kk lines — the division into subsegments. The ii -th line should contain two integers lil_i and rir_i ( 1lirin1 \le l_i \le r_i \le n ) — the boundaries of the ii -th subsegment.

The following conditions must be satisfied:

  • For all 1jk11 \le j \le k - 1 , lj+1=rj+1l_{j + 1} = r_j + 1 ;
  • l1=1l_1 = 1 , rk=nr_k = n .

If there are multiple possible solutions, output any of them.

输入输出样例

  • 输入#1

    5
    2
    0 0
    5
    0 1 2 3 4
    8
    0 1 7 1 0 1 0 3
    3
    2 2 2
    4
    0 1 2 0

    输出#1

    2
    1 1
    2 2
    -1
    3
    1 3
    4 5
    6 8
    3
    1 1
    2 2
    3 3
    -1

说明/提示

In the first test case, the array aa can be divided into 22 subsegments with boundaries [1,1][1, 1] and [2,2][2, 2] :

  • MEX\operatorname{MEX} of the first subsegment [0][0] is 11 , as 00 belongs to the subsegment, but 11 does not.
  • MEX\operatorname{MEX} of the second subsegment [0][0] is 11 , as 00 belongs to the subsegment, but 11 does not.

In the second test case, it can be proven that the required division does not exist.

In the third test case, the array aa can be divided into 33 subsegments with boundaries [1,3][1, 3] , [4,5][4, 5] , [6,8][6, 8] :

  • MEX\operatorname{MEX} of the first subsegment [0,1,7][0, 1, 7] is 22 , as 00 and 11 belong to the subsegment, but 22 does not.
  • MEX\operatorname{MEX} of the second subsegment [1,0][1, 0] is 22 , as 00 and 11 belong to the subsegment, but 22 does not.
  • MEX\operatorname{MEX} of the third subsegment [1,0,3][1, 0, 3] is 22 , as 00 and 11 belong to the subsegment, but 22 does not.
首页