随笔分类 - 数据结构——分块和莫队
摘要:"ref" cpp include include include include using namespace std; typedef long long ll; int n, q, a[100005], l[100005], r[100005], sta[100005], din, blc,
阅读全文
摘要:这竟然是一道分块题…… cpp include include include include using namespace std; int n, m, q, blc, qnt, fa[50005], mxa[50005], mxb[50005], sz[50005], bcj, ans[500
阅读全文
摘要:"ref" cpp include include include include using namespace std; typedef long long ll; int ua, ub, uc, ud, n, m, a[50005], chu[50005], blc, bel[50005],
阅读全文
摘要:分块+权值逆序对
阅读全文
摘要:```cpp include include include include using namespace std; int n, m, a[50005], blc, bel[50005], cnt[50005]; long long ansfz[50005], ansfm[50005], ans
阅读全文
摘要:算法竞赛进阶指南p219,这里是分块。 当然也可以树套树来个动态二维数点。 cpp include include include include include using namespace std; typedef long long ll; int xx, yy, n, uu, vv, bl
阅读全文
摘要:```cpp #include #include #include #include #include #include #include using namespace std; int n, m, bel[40005], a[40005], blc, f[1005][1005], cnt[40005], idx, ans; int val[40005], uu, vv; map ...
阅读全文
摘要:"hzwer的讲解" 一 给出一个长为 $n$ 的数列,以及 $n$ 个操作,操作涉及区间加法,单点查值。 cpp include include include include include using namespace std; int n, blc, a[50005], tag[50005
阅读全文
摘要:可以用树状数组,线段树,分块做。代码是分块 cpp include include include using namespace std; typedef long long ll; int n, m, uu, vv, ww, blc, bel[100005]; ll sum[100005], t
阅读全文
摘要:参考 "这里" 我们先预处理模数在 $\sqrt{n}$ 以内的询问。 要是模数在 $\sqrt{n}$ 以外,直接暴力统计,反正这样的数又不会超过 $\sqrt{n}$ 个。 修改的时候也是。要是在 $\sqrt{n}$ 以内就把预处理的答案减去原数加上新数。 然后再把原数改掉。 然后再优化一下,
阅读全文
摘要:莫队裸题还不带修改 cpp include include include include using namespace std; int n, m, qcnt, ans, col[1000005], bse, blc[50005], a[50005], qwq[200005]; struct Q
阅读全文
摘要:莫队算法模板 推荐阅读 "这篇博客" cpp include include include include using namespace std; int n, m, bse, blc[10005], a[10005], qCnt, cCnt, qwq[10005], ans=0; int cn
阅读全文