05 2022 档案
线段树模板
摘要:区间加法,区间查询 #include<bits/stdc++.h> #define int long long using namespace std; const int N=1e5+5; struct SegmentTree { int l,r; int sum,add; #define l(x 阅读全文
posted @ 2022-05-17 22:59 我疯故我在 阅读(10) 评论(0) 推荐(0) 编辑
延迟标记
摘要:用途:区间增加,区间查询 扩展: “永久性标记” 用途:二维线段树和可持久化线段树难以下传标记的情况下有所应用 局限性非常大,对线段树维护的信息和标记的性质有特殊要求。 阅读全文
posted @ 2022-05-17 20:50 我疯故我在 阅读(110) 评论(0) 推荐(0) 编辑
树状数组与逆序对
摘要:当数据范围较大需要离散化,因此需要排序,所以这种情况下不如直接用归并排序。 #include<bits/stdc++.h> using namespace std; const int N=5e5+5; int n; int a[N],b[N]; int c[N]; int ask(int x) { 阅读全文
posted @ 2022-05-15 09:21 我疯故我在 阅读(25) 评论(0) 推荐(0) 编辑
模板
摘要:模板一(单点操作): #include<bits/stdc++.h> using namespace std; const int N=5e5+5; int n,m; int a[N]; int c[N]; void add(int x,int y) { for(; x<=n; x+=x&-x) c 阅读全文
posted @ 2022-05-14 18:02 我疯故我在 阅读(26) 评论(0) 推荐(0) 编辑
从图的某个点开始的深度(bfs)
摘要:如:从1开始 bfs 1 queue<int> q; 2 q.push(1); 3 c[1]=1; 4 v[1]=1; 5 while(q.size()) { 6 int x=q.front(); 7 q.pop(); 8 for(int i=head[x]; i; i=nxt[i]) { 9 in 阅读全文
posted @ 2022-05-10 20:29 我疯故我在 阅读(49) 评论(0) 推荐(0) 编辑




点击右上角即可分享
微信分享提示