线段树
growing_up_
这个作者很懒,什么都没留下…
展开
-
离散化+线段树 poj2528
//离散化+线段树#include #include #include #define CLR(A) memset(A,0,sizeof(A))using namespace std;const int N = 20005;int col[N * 4], vis[N];int le[N], ri[N], c[N * 2], ans;void pushdown(int p)转载 2017-09-13 17:45:53 · 203 阅读 · 0 评论 -
hdu1166 单点修改区间查询
#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#includeusing namespace std;const int maxn = 50005;int sum[maxn<<2];void push_up(int root){ sum[root] = sum[root << 1] + sum原创 2017-09-13 21:33:28 · 202 阅读 · 0 评论 -
区间修改区间查询 lazy标记
//区间修改,区间查询#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#define ll long longusing namespace std;const int maxn = 100005;struct node { ll sum; int lazy;}T[maxn<<转载 2017-09-14 19:24:55 · 314 阅读 · 0 评论 -
线段树求某值之前或之后与其差值不小于k的最近位置
#include #include #include #include using namespace std;#define maxn 100000 + 10#define lson L, mid, rt<<1#define rson mid+1, R, rt<<1|1int n, k;int a[maxn];int ans;struct Node{ int转载 2017-09-16 15:48:17 · 231 阅读 · 0 评论 -
一个智障的求逆序对的问题
#include#include#include#include#define ll long long using namespace std;const int N = 5010;int bit[N];int n;void add(int i){ while (i <= n) { bit[i] += 1; i += (i&-i); }}int sum(i转载 2017-09-16 21:33:28 · 147 阅读 · 0 评论 -
线段树 单点修改,区间修改
//单点修改,区间查询#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#includeusing namespace std;const int maxn = 50005;int sum[maxn<<2];void push_up(int root){ sum[root] = sum[root转载 2017-10-20 17:55:18 · 295 阅读 · 0 评论 -
区间修改,区间查询
//区间修改,区间查询#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#define ll long longusing namespace std;const int maxn = 100005;struct node { ll sum; int lazy;}T[maxn<<转载 2017-10-20 17:56:06 · 419 阅读 · 0 评论