307710: CF1400D. Zigzags
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Zigzags
题意翻译
## 题目描述 给出 $n$ 个数 $a_1,a_2,\cdots,a_n$。求问有多少个四元组 $(i,j,k,l)$,使得这个四元组满足下列条件: - $1 \leq i<j<k<l \leq n$; - $a_i=a_k$ 并且 $a_j=a_l$。 ## 输入格式 第一行输入一个数 $t$,表示数据组数。 对于每组数据,第一行输入一个数 $n$,表示有多少个数。 对于每组数据,第二行输入 $n$ 个数,表示 $a_1,a_2,\cdots,a_n$。 ## 输出格式 对于每一组数据,输出合法四元组的个数。题目描述
You are given an array $ a_1, a_2 \dots a_n $ . Calculate the number of tuples $ (i, j, k, l) $ such that: - $ 1 \le i < j < k < l \le n $ ; - $ a_i = a_k $ and $ a_j = a_l $ ;输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases. The first line of each test case contains a single integer $ n $ ( $ 4 \le n \le 3000 $ ) — the size of the array $ a $ . The second line of each test case contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le n $ ) — the array $ a $ . It's guaranteed that the sum of $ n $ in one test doesn't exceed $ 3000 $ .
输出格式
For each test case, print the number of described tuples.
输入输出样例
输入样例 #1
2
5
2 2 2 2 2
6
1 3 3 1 2 3
输出样例 #1
5
2