CF1917A.Least Product

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given an array of integers a1,a2,,ana_1, a_2, \dots, a_n . You can perform the following operation any number of times (possibly zero):

  • Choose any element aia_i from the array and change its value to any integer between 00 and aia_i (inclusive). More formally, if ai<0a_i < 0 , replace aia_i with any integer in [ai,0][a_i, 0] , otherwise replace aia_i with any integer in [0,ai][0, a_i] .

Let rr be the minimum possible product of all the aia_i after performing the operation any number of times.

Find the minimum number of operations required to make the product equal to rr . Also, print one such shortest sequence of operations. If there are multiple answers, you can print any of them.

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt ( 1t5001 \leq t \leq 500 ) - the number of test cases. This is followed by their description.

The first line of each test case contains the a single integer nn ( 1n1001 \leq n \leq 100 ) — the length of the array.

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 ).

输出格式

For each test case:

  • The first line must contain the minimum number of operations kk ( 0kn0 \leq k \leq n ).
  • The jj -th of the next kk lines must contain two integers ii and xx , which represent the jj -th operation. That operation consists in replacing aia_i with xx .

输入输出样例

  • 输入#1

    4
    1
    155
    4
    2 8 -1 3
    4
    -1 0 -2 -5
    4
    -15 -75 -25 -30

    输出#1

    1
    1 0
    0
    0
    1
    3 0

说明/提示

In the first test case, we can change the value of the first integer into 00 and the product will become 00 , which is the minimum possible.

In the second test case, initially, the product of integers is equal to 28(1)3=482 \cdot 8 \cdot (-1) \cdot 3 = -48 which is the minimum possible, so we should do nothing in this case.

首页