CF1635C.Differential Sorting

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given an array aa of nn elements.

Your can perform the following operation no more than nn times: Select three indices x,y,zx,y,z (1x<y<zn)(1 \leq x < y < z \leq n) and replace axa_x with ayaza_y - a_z . After the operation, ax|a_x| need to be less than 101810^{18} .

Your goal is to make the resulting array non-decreasing. If there are multiple solutions, you can output any. If it is impossible to achieve, you should report it as well.

输入格式

Each test contains multiple test cases. The first line will contain a single integer tt (1t10000)(1 \leq t \leq 10000) — the number of test cases. Then tt test cases follow.

The first line of each test case contains a single integer nn (3n2105)(3 \leq n \leq 2 \cdot 10^5) — the size of the array aa .

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots ,a_n (109ai109)(-10^9 \leq a_i \leq 10^9) , the elements of aa .

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, print 1-1 in a single line if there is no solution. Otherwise in the first line you should print a single integer mm (0mn)(0 \leq m \leq n) — number of operations you performed.

Then the ii -th of the following mm lines should contain three integers x,y,zx,y,z (1x<y<zn)(1 \leq x < y < z \leq n) — description of the ii -th operation.

If there are multiple solutions, you can output any. Note that you don't have to minimize the number of operations in this task.

输入输出样例

  • 输入#1

    3
    5
    5 -4 2 -1 2
    3
    4 3 2
    3
    -3 -2 -1

    输出#1

    2
    1 2 3
    3 4 5
    -1
    0

说明/提示

In the first example, the array becomes

[6,4,2,1,2][-6,-4,2,-1,2] after the first operation,

[6,4,3,1,2][-6,-4,-3,-1,2] after the second operation.

In the second example, it is impossible to make the array sorted after any sequence of operations.

In the third example, the array is already sorted, so we don't need to perform any operations.

首页