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…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3781 就是莫队,左端点分块排序,块内按右端点排序,然后直接做即可. 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; typedef long long ll…