
树状数组
幽殇默
他时若遂凌云志,敢笑黄巢不丈夫。
展开
-
244. 谜一样的牛【树状数组的一个特殊扩展】
https://www.acwing.com/problem/content/245/ 呆呆大佬的详细题解 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int tr[N],h[N],ans[N],n; int lowbit(int x){return x&(-x);} void add(int x,int c) { for(int i=x;i<=n;i+=lowbit(i)) tr[i].原创 2021-10-11 19:27:19 · 163 阅读 · 0 评论 -
P3368 【模板】树状数组 2
https://www.luogu.com.cn/problem/P3368 #include<bits/stdc++.h> using namespace std; const int N=1e5*5+10; typedef long long int LL; LL tr[N],a[N],n,m; int lowbit(int x){return x&(-x);} void add(int x,int c) { for(int i=x;i<=n;i+=lowbit(i)) t.原创 2021-10-11 18:58:02 · 92 阅读 · 0 评论 -
P3374 【模板】树状数组 1
https://www.luogu.com.cn/problem/P3374 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const int N=1e5*5+10; LL tr[N],a[N],n,m; int lowbit(int x){return x&(-x);} void add(int x,int c) { for(int i=x;i<=n;i+=lowbit(i)) t.原创 2021-10-11 18:50:15 · 131 阅读 · 0 评论 -
243. 一个简单的整数问题2【树状数组 区间查询 区间修改】
https://www.acwing.com/problem/content/244/ 上图摘自acwing的铅笔佬 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const int N=1e5+10; LL tr1[N],tr2[N],n,m,a[N]; int lowbit(int x){return x&(-x);} LL add(LL tr[],LL x,LL c) { f.原创 2021-10-11 18:44:16 · 145 阅读 · 0 评论 -
242. 一个简单的整数问题【树状数组的简单扩展 区间修改 单点查询】
https://www.acwing.com/problem/content/description/248/ #include<bits/stdc++.h> using namespace std; const int N=1e5+10; typedef long long int LL; LL a[N],tr[N],n,m; int lowbit(int x){return x&(-x);} void add(int x,int c) { for(int i=x;i<.原创 2021-10-11 14:46:46 · 106 阅读 · 0 评论 -
241. 楼兰图腾【树状数组】
https://www.acwing.com/problem/content/243/ #include<bits/stdc++.h> using namespace std; const int N=1e5*2+10; typedef long long int LL; LL tr[N],up[N],down[N],a[N]; int n; int lowbit(int x){return x&(-x);} int add(int x,int c) { for(int i=x.原创 2021-10-11 13:50:08 · 91 阅读 · 0 评论