https://codeforces.com/contest/1527/problem/C
A sequence b is a subsegment of a sequence a if b can be obtained from a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
——题意看清!!several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
弄成子列了,不要这样。还用py做了大数。。
比赛时,不要慌,思路仍然要想透想深一点
#include<bits/stdc++.h>
#ifdef LOCAL
FILE*FP=freopen("text.in","r",stdin);
#endif
using namespace std;
#define int unsigned long long
//题意看清!
map<int,int>m;
signed main(){
int t;
scanf("%llu",&t);//long long输入
while(t--){
int n;
scanf("%llu",&n);
m.clear();
int te,sum=0;
for(int i=0;i<n;i++){
scanf("%llu",&te);
sum+=m[te]*(n-i);
m[te]+=(i+1);
}
printf("%llu\n",sum);
}
return 0;
}