http://www.lydsy.com/JudgeOnline/problem.php?id=3781 N个数的序列,每次询问区间中每种数字出现次数的平方和,可以离线. 丢模板: #include <bits/stdc++.h> using namespace std; const int MAXN=50005, S=225; int be[MAXN], A[MAXN], c[MAXN], ans[MAXN], N, M, K; struct Qry{ int l, r, id; bool…
1.莫队算法 TLE 80 #include<bits/stdc++.h> #define rep(i,x,y) for(register int i=x;i<=y;i++) using namespace std; ,M=; int h[N],n,m,a[N],ans[M]; struct node{ int l,r,id; bool operator<(const node&b)const{ if(h[l]==h[b.l])return r<b.r; return…