线段树
@阿奇@
做一个勤勉、有趣、善良的人
展开
-
poj2352
输入顺序是有规律的,只需要x的值就可以建树了,同时,边建树边查找#include <iostream> #include <stdio.h> #include <algorithm>using namespace std; const int maxn=32010; int tree[4*maxn]; int x[maxn]; int level[15010]; void build(int p,i原创 2017-12-11 15:08:26 · 110 阅读 · 0 评论 -
poj2299&&归并排序
#include <iostream> #include <stdio.h> //error: reference to 'left' is ambiguous|把left换成left_就好了 using namespace std; const int maxn=500010; const int INF=0x7fffffff; int s[maxn],left_[maxn],right_[max原创 2017-12-11 21:07:09 · 269 阅读 · 0 评论 -
poj2528&&线段树模板
二叉树模板,可实现查找,更新#include <iostream> #include <stdio.h> using namespace std; #define N 111111 long long sum[N<<2];//数组开的太大,要用宏定义,不然RE long long add[N<<2]; void pushdown(int m,int rt) { if(add[rt])原创 2017-12-12 20:36:00 · 110 阅读 · 0 评论 -
poj2528
//离散化+线段树+二分 #include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; #define maxn 10010 int n,m,ans; int li[maxn],ri[maxn],hash_color[maxn],a[maxn*2*2*2],co原创 2017-12-13 12:30:37 · 139 阅读 · 0 评论 -
hdu4417
#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #define N 100010 using namespace std; int n,m; int cnt[N*4],ans[N]; struct node { int h; int pos; bool operat原创 2017-12-14 16:17:13 · 205 阅读 · 0 评论 -
数据结构总结之线段树
1.线段树模板,先建树后,可实现查找,更新 poj2528#include <iostream> #include <stdio.h> using namespace std; #define N 111111 long long sum[N<<2];//数组开的太大,要用宏定义,不然RE long long add[N<<2]; void pushdown(int m,int rt) {原创 2017-12-18 21:32:16 · 148 阅读 · 0 评论