1692. Kanade's trio

时间限制 2000 ms   内存限制 512 MB


Give you an array $A[1..n]$, you need to calculate how many tuples $(i,j,k)$ satisfy that $(i<j<k)$ and $((A[i]~xor~A[j])<(A[j]~xor~A[k]))$

There are T test cases.

<j<k)$ and="" $((a[i]~xor~a[j])<(a[j]~xor~a[k]))$


$1\leq T\leq 20$



$1\leq \sum n\leq 5*10^5$



$0\leq A[i] <2^{30}$</j<k)$>


输入数据

There is only one integer T on first line.

For each test case , the first line consists of one integer $n$ ,and the second line consists of $n$ integers which means the array $A[1..n]$

输出数据

For each test case , output an integer , which means the answer.

样例输入

复制
1

5

1 2 3 4 5 \n
\n
 \n
\n
 · · · · \n

样例输出

复制
6 \n

提交

请先 登录

Source

2017 Multi-University Training Contest - Team 3

© 2025 FAQs Contact About