#include <algorithm> #include <iostream> #include <cstdio> #include <cmath> using namespace std; int n, m, a[50005], blc, bel[50005], cnt[50005]; long long ansfz[50005], ansfm[50005], ans; struct Node{ int l, r, id; }nd[50005]; boo…
莫队..先按sqrt(n)分块, 然后按块的顺序对询问排序, 同块就按右端点排序. 然后就按排序后的顺序暴力求解即可. 时间复杂度O(n1.5) ------------------------------------------------------------------------------ #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 50009;…