随笔分类 -  线段树、树状数组、分块

摘要:1 /* 2 set 自带的 lower_bound 和 upper_bound 的时间复杂度为 O(logn)。 3 4 但使用 algorithm 库中的 lower_bound 和 upper_bound 函数对 set 中的元素进行查询,时间复杂度为 0(n)。 5 6 总结:对于可随机访问 阅读全文
posted @ 2022-04-09 18:39 matt-11 阅读(39) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=200200; 5 int dep[N],fa[N][30],color[N],bin[N],blg[N],ord[N],in 阅读全文
posted @ 2022-04-03 13:58 matt-11 阅读(30) 评论(0) 推荐(0) 编辑
摘要:最坑的是输入除了'Q','R'还有其他字母; 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=1e6+5; 5 int color[N],blg[N],cnt[N],ans[ 阅读全文
posted @ 2022-03-29 22:59 matt-11 阅读(24) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=2e5+5; 5 int n,m,p,l=1,r=0,tot=0; 6 ll blg[N],suff[N],bin[N],f[ 阅读全文
posted @ 2022-03-27 22:27 matt-11 阅读(25) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=5e4+5; 5 ll a[N],blg[N],cnt[N]; 6 string ans[N]; 7 inline ll gc 阅读全文
posted @ 2022-03-27 17:38 matt-11 阅读(27) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=1e5+5; 5 vector<ll>v[N]; 6 ll a[N],tag[N],blg[N],L[N],R[N],bloc 阅读全文
posted @ 2022-03-08 20:23 matt-11 阅读(28) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=5e4+5; 5 vector<ll>v[50005]; 6 ll a[N],tag[N],blg[N],L[N],R[N], 阅读全文
posted @ 2022-03-08 07:57 matt-11 阅读(22) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=5e4+5; 5 int blg[N],L[N],R[N],tag[N],sum[N],a[N],block,tot; 6 v 阅读全文
posted @ 2022-03-06 22:39 matt-11 阅读(39) 评论(0) 推荐(0) 编辑
摘要:1 #include<iostream> 2 #include<cstdio> 3 #include<vector> 4 #include<cstring> 5 #define ls (x<<1) 6 #define rs (x<<1|1) 7 using namespace std; 8 cons 阅读全文
posted @ 2022-02-02 22:45 matt-11 阅读(30) 评论(0) 推荐(0) 编辑
摘要:Apple Tree Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 48841 Accepted: 14278 Description There is an apple tree outside of kaka's house 阅读全文
posted @ 2022-01-28 22:11 matt-11 阅读(29) 评论(0) 推荐(0) 编辑
摘要:Tunnel Warfare Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 10964 Accepted: 4538 Description During the War of Resistance Against Japan 阅读全文
posted @ 2022-01-28 20:27 matt-11 阅读(23) 评论(0) 推荐(0) 编辑
摘要:考虑如果顺序模拟会T,注意到最后一个元素一定在它确定的位置,考虑从后往前放,找第k个空位,完美解决这题; 1 #include<iostream> 2 #include<cstdio> 3 #define ls (x<<1) 4 #define rs (x<<1|1) 5 using namespa 阅读全文
posted @ 2022-01-11 22:19 matt-11 阅读(21) 评论(0) 推荐(0) 编辑
摘要:P5490 【模板】扫描线 这题线段树的节点表示的是区间,树上节点x表示的区间【l,r】是实际点的[l,r+1]区间;因为我们纯用点一一对应 当标记落到一个点时 没有任何意义;标记更新,如果当前节点被标记,说明区间被标记,如果当前节点没被标记,返回左节点和右节点被标记的总长度 sum[x]维护的是节 阅读全文
posted @ 2022-01-10 21:06 matt-11 阅读(48) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 #define ls (x<<1) 3 #define rs (x<<1|1) 4 #define rep(i,a,b) for(int i=a;i<=b;i++) 5 #define pb(a) push_back(a) 6 using na 阅读全文
posted @ 2022-01-07 21:44 matt-11 阅读(33) 评论(0) 推荐(0) 编辑
摘要:这题是线段树的区间加、区间修改和懒标记,注意开long long 1 #include<bits/stdc++.h> 2 #define ls (x<<1) 3 #define rs (x<<1|1) 4 #define rep(i,a,b) for(int i=a;i<=b;i++) 5 #def 阅读全文
posted @ 2022-01-07 17:04 matt-11 阅读(42) 评论(0) 推荐(0) 编辑
摘要:最近在看树状数组和线段树,没完整看完,把目前学的暂时记录,后续再补。 线段树和树状数组都是对区间操作的数据结构 1 #define ls (x<<1) 2 #define rs (x<<1|1) 3 using namespace std; 4 const int N=1e5+5; 5 int su 阅读全文
posted @ 2021-11-22 11:56 matt-11 阅读(27) 评论(0) 推荐(0) 编辑

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