CF1400D.Zigzags
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2…an . Calculate the number of tuples (i,j,k,l) such that:
- 1≤i<j<k<l≤n ;
- ai=ak and aj=al ;
输入格式
The first line contains a single integer t ( 1≤t≤100 ) — the number of test cases.
The first line of each test case contains a single integer n ( 4≤n≤3000 ) — the size of the array a .
The second line of each test case contains n integers a1,a2,…,an ( 1≤ai≤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
说明/提示
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) : a1=a4 and a2=a6 ;
- (1,3,4,6) : a1=a4 and a3=a6 .