
线段树
ThreeWater-
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CF 6E 线段树 or Multiset or 双端队列维护区间最值
给你一个序列,让你求一个区间中最大值和最小值相差不过k的最长连续序列的长度#include <stdio.h> #include <string.h> #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 inline int MAX(int a,int b) {return a>b?a:b;} inline int MIN(int a,int b) {retu原创 2016-08-16 20:53:11 · 378 阅读 · 0 评论 -
hdu3966 树链剖分(入门,点)
#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> #include <vector> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; typedef long long原创 2016-10-03 14:39:01 · 367 阅读 · 0 评论 -
spoj375树链剖分 (链)
#include <cstdio> #include <cstring> #include <algorithm> const int N=50010; using namespace std; struct node { int u,v,w; }e[N]; struct d { int nxt,to; }edge[N<<1]; int cnt,tim,head[N]; int a[原创 2016-10-05 16:53:38 · 225 阅读 · 0 评论 -
poj3237 树链剖分
WA了N发, 每次取相反数的时候,都需要交换最大值和最小值,这样才能维护动态的平衡,因为lazy标志的原因,取相反数,没有更新到底,所以如果只维护一个最大值会出问题。#include <cstdio> #include <cstring> #include <algorithm> const int N=50010; using namespace std; struct node {原创 2016-10-05 17:21:38 · 228 阅读 · 0 评论 -
hdu5692 (dfs序+线段树)
忘记初始化mle n次 GG #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #define pb(a) push_back(a) using namespace std; typ原创 2016-10-08 01:02:12 · 333 阅读 · 0 评论 -
线段树区间更新760E
入栈为1,出栈为-1,区间更新即可 然后维护最大值, 从右到左找第一个等于1的位置。#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+5; #define ls l,mid,rt<<1 #define rs mid+1,r,rt<<1|1 int a[N<<2]={0},lazy[原创 2017-02-17 09:26:38 · 218 阅读 · 0 评论 -
线段树模板
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ls l,mid,rt<<1 #define rs mid+1,r,rt<<1|1 inline int MAX(int a,int b) {return a>b?a:b;} const int N=50005; int sum[N<<2]; voi原创 2017-10-10 18:30:33 · 620 阅读 · 0 评论