CF1400D Zigzags
题目描述
给出 $n$ 个数 $a_1,a_2,\cdots,a_n$。求问有多少个四元组 $(i,j,k,l)$,使得这个四元组满足下列条件:
- $1 \leq i
输入格式
第一行输入一个数 $t$,表示数据组数。
对于每组数据,第一行输入一个数 $n$,表示有多少个数。
对于每组数据,第二行输入 $n$ 个数,表示 $a_1,a_2,\cdots,a_n$。
输出格式
对于每一组数据,输出合法四元组的个数。
说明/提示
In the first test case, for any four indices $ i < j < k < l $ are valid, so the answer is the number of tuples.
In the second test case, there are $ 2 $ valid tuples:
- $ (1, 2, 4, 6) $ : $ a_1 = a_4 $ and $ a_2 = a_6 $ ;
- $ (1, 3, 4, 6) $ : $ a_1 = a_4 $ and $ a_3 = a_6 $ .