P21295 [CodeChef] POSPROD
普及-
题目描述

You are given an array A of length N. Find the number of pairs of indices (i,j) such that
1 ≤ i < j ≤ N
$A_{i} \cdot A_{j} > 0$

------ Input Format ------

  • The first line contains a single integer T - the number of test cases. Then the test cases follow.
  • The first line of each test case contains an integer N - the size of the array A.
  • The second line of each test case contains $N space-separated integers A_{1}, A_{2}, \dots, A_{N}$ denoting the array A.

------ Output Format ------

For each test case, output the number of pairs which satisfy the above conditions.

------ Constraints ------

$1 ≤ T ≤ 1000$
$2 ≤ N ≤ 10^{5}$
$-10^{4} ≤ A_{i} ≤ 10^{4}$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$

----- Sample Input 1 ------
3
5
1 -3 0 2 -1
4
-1 -1 -1 -1
4
0 1 2 3

----- Sample Output 1 ------
2
6
3

----- explanation 1 ------
Test case 1: The pairs which satisfy the conditions are $(1,4)$ and $(2,5)$.

Test case 2: The pairs which satisfy the conditions are $(1,2)$, $(1,3)$, $(1,4)$, $(2,3)$, $(2,4)$ and $(3,4)$.

Test case 3: The pairs which satisfy the conditions are $(2,3)$, $(2,4)$ and $(3,4)$.

输入格式

见题面

输出格式

见题面

样例输入
3 5 1 -3 0 2 -1 4 -1 -1 -1 -1 4 0 1 2 3
样例输出
2 6 3