![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
Jerry99s
OI -> ACM -> AI
展开
-
线段树模板题
题目:codevs1080 1081 1082 分析:1080写的树状数组,1081 1082写的线段树,全是模板 代码: 1080#include <cstdio>#include <algorithm>using namespace std;const int Tmax=400010;int n,p,v;long long int sum[Tmax];/*int原创 2015-06-13 21:57:06 · 257 阅读 · 0 评论 -
HDU6356 Glad You Came (2018多校第五场1007) (假线段树 / ST表RMQ)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6356题意: 给三个数X,Y,Z; 给定一个依赖于XYZ的随机数生成函数; m个操作,每次让区间[Li,Ri]内的数ai=max(ai,v); 求⨁(i⋅ai),⨁是异或和;分析: 法一:线段树 minv[x]记录区间最小值; 若minv[x]>=v,则剪枝(重点,不然TLE);...原创 2018-08-06 19:31:06 · 219 阅读 · 0 评论 -
HDU1698 Just a Hook (线段树Lazy_tag模板题)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1698代码:#include <cstdio>#include <algorithm>#include <cstring>using namespace std;typedef long long ll;const int tmax=1e5+5;i...原创 2018-08-14 20:17:06 · 173 阅读 · 0 评论 -
HDU 6315 Naive Operations (2018多校第2场1007) (线段树+树状数组)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6315题意: 给定一个序列b[i]; 数列a[i]初始全0; 每次操作可以向a中[l,r]区间+1; 每次求分析: 首先将线段树中第i位赋值为b[i],代表i位需要加b[i]次才会对答案+1; 每次区间加操作,认为是对区间-1; 用线段树记录区间最小值及最小值出现的位置; 若区间最小...原创 2018-08-03 15:23:10 · 168 阅读 · 0 评论 -
Codeforces 292E. Copying Data (zkw线段树+加tag)
题目: http://codeforces.com/problemset/problem/292/E分析:用了zkw线段树+tag的方式乱搞。代码://jerry99#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long llong;const int tmax=1e5+5;int n,m,a[tma...原创 2019-01-22 18:49:58 · 295 阅读 · 0 评论 -
HDU 6606. Distribution of books (DP+线段树)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=6606题意:n个数,可以选择前m(m自定)个数分成k块,问每块的数字和的最大值最小是多少。n∈[1, 2e5],k∈[1, n]分析:先求前缀和leftSum[],然后对前缀和离散化;对leftSum[]排序并去重得到pre[];设f[i]=前i个数最多能分成的块数;二分答案,设答案为x;...原创 2019-07-30 11:50:16 · 684 阅读 · 0 评论