当前位置: 首页 > wzjs >正文

哪种网站开发简单广州品牌策划公司排行

哪种网站开发简单,广州品牌策划公司排行,知名男艺人工作室,四川成都住建局官网#PermanentNotes/algorithm 思想 首先关于树有许多类型,这里我们主要首线段树,整体思想就是将一个大区间进行拆分,拆分成各个小区间,在我们进行查找,更新时,就是对区间的查找更新 类型 初始化,构建树 代码 const int Z 1e7; const ll INF 1e18; const int maxn 1e5 10…

#PermanentNotes/algorithm

思想

首先关于树有许多类型,这里我们主要首线段树,整体思想就是将一个大区间进行拆分,拆分成各个小区间,在我们进行查找,更新时,就是对区间的查找更新

类型

初始化,构建树

代码

const int Z = 1e7;
const ll INF = 1e18;
const int maxn= 1e5 + 10;
const int maxnn = maxn << 2;
int N, M, E;ll tree[maxnn];void build(int l, int r, int k) {if (l == r) {tree[k] = INF;//在这里,我经常将它的节点写成它的l return;}int mid = l + r >> 1;int lc = k << 1;int rc = k << 1 | 1;build(l, mid, lc);build(mid + 1, r, rc);tree[k] = min(tree[lc], tree[rc]);
}

在我们的初始化当中,一定要根据题意,确定我们最开始要初始的值(我们假设我们求的是一个区间最小值,那么将每个区间都初始化为最大值)

单点更新

代码

这里,我们假设求最小值


void pushup(int rt)
{tree[rt] = min(tree[rt << 1], tree[rt << 1 | 1]);
}void update(int pos,ll c,int l,int r,int rt)
{if(l==r){tree[rt]=min(tree[rt],c);return ;}int m=(l+r)>>1;if(pos<=m) update(pos,c,lson);if(pos> m) update(pos,c,rson);pushup(rt);
}

区间查找

我们假设查找一个区间的最小值

代码

ll query(int L, int R, int l, int r, int rt)
{if (L <= l && r <= R) {return tree[rt];}int m = (l + r) >> 1;ll ret = inf;int lc=rt<<1;int rc=rt<<1|1;if (L <= m) ret = min(ret, query(L, R, l,m,lc));if (R > m) ret = min(ret, query(L, R, m+1,r,rc));return ret;
}

区间修改(懒标记法)

每次在进行左右区间(lc,rc)操作之前,先进行pushdown对,对lc,rc操作完毕之后再pushup


typedef long long ll;#define lc p<<1
#define rc p<<1|1const int N = 1e5;
int a[N];
struct node {int l;int r;ll sum;ll add;
}tr[4 * N];void pushup(int p) {tr[p].sum = tr[lc].sum + tr[rc].sum;
}
void pushdown(int p) {if (tr[p].add) {tr[lc].sum += (tr[lc].r - tr[lc].l + 1) * tr[p].add;tr[rc].sum += (tr[rc].r - tr[rc].l + 1) * tr[p].add;tr[lc].add += tr[p].add;tr[rc].add += tr[p].add;tr[p].add = 0;}
}void build(int p, int l, int r) {tr[p] = { l,r,a[l],0 };if (l == r)return;int m = l + r >> 1;build(lc, l, m);build(rc, m + 1, r);pushup(p);
}void update(int p, int x, int y, int k) {if (x <= tr[p].l && tr[p].r <= y) {tr[p].sum += (tr[p].r - tr[p].l + 1) * k;tr[p].add += k;return;}int m = tr[p].l + tr[p].r >> 1;pushdown(p);if (x <= m)update(lc, x, y, k);if (m < y)update(rc, x, y, k);pushup(p);
}ll query(int p, int x, int y) {if (x <= tr[p].l && tr[p].r <= y)return tr[p].sum;int m = tr[p].l + tr[p].r >> 1;pushdown(p);ll sum = 0;if (x <= m)sum += query(lc, x, y);if (m < y)sum += query(rc, x, y);return sum;
}

推荐视频b站up董晓算法我的算法都是在这儿学的

线段树例题
acwing243
洛谷p3372
洛谷p3373


文章转载自:

http://qRq59yh0.hkshy.cn
http://9Lld1WBC.hkshy.cn
http://cjjueCD4.hkshy.cn
http://KZQvDFOU.hkshy.cn
http://1n7lXWJ7.hkshy.cn
http://bcoqdZGW.hkshy.cn
http://p0sIkOQy.hkshy.cn
http://XORQDEbb.hkshy.cn
http://eivutI8M.hkshy.cn
http://eqc9E4Dk.hkshy.cn
http://j212BAEP.hkshy.cn
http://oroL1tqj.hkshy.cn
http://3ek22Ehe.hkshy.cn
http://kzVRduF0.hkshy.cn
http://1ATJqx3k.hkshy.cn
http://ON1rn5kJ.hkshy.cn
http://edIzhwax.hkshy.cn
http://itlbtBm5.hkshy.cn
http://UkIfi4Hc.hkshy.cn
http://2NC7GXQd.hkshy.cn
http://0o9jSV5n.hkshy.cn
http://JxE2Q5W6.hkshy.cn
http://XICJRaph.hkshy.cn
http://FPOOayW4.hkshy.cn
http://sWSHr82t.hkshy.cn
http://aiRQeL1i.hkshy.cn
http://SdOWSGaH.hkshy.cn
http://yfMHR0Yh.hkshy.cn
http://p2iHL1bT.hkshy.cn
http://w8Zoytab.hkshy.cn
http://www.dtcms.com/wzjs/699720.html

相关文章:

  • 郑州二七区做网站公司网站开发有哪些
  • 制作网页的网站费用属于资本性支出吗个人做网站备案多少钱
  • 网站上线前要做哪些准备wordpress 文章列表插件
  • 如何做网站seo韩小培网站开发形式
  • 权威网站设计宣传信息网网站规划书
  • 中小企业网站开发韵茵福建百益建设集团有限公司网站
  • 网页设计与网站建设过程洛谷网站中小玉文具怎么做
  • 织梦能不能做门户网站影响网站用户体验
  • 优客逸家网站源码免费网站在线制作
  • 用C语言做网站登录界面重庆市住房和城乡建设网站
  • 网站建设字体我的世界做mc壁纸的网站
  • 潭州教育网站开发南京网站设计开发
  • 都匀网站.asp 网站
  • 网站宽度 像素无锡网站建设详细内容
  • 网站引导页的作用网站建设前期开发
  • 贵州省城乡和建设厅网站首页淘宝网站的推广与优化
  • 烟台网站制作步骤个人电子邮件注册网站申请
  • 安徽网新科技有限公司网站开发百度下载安装到桌面
  • 济南建设工程备案网站崇左市城市投资建设有限公司网站
  • 建设网站的协议范本中国菲律宾签证免签吗
  • 临沂网站建设小程序怎么做网站端口代理
  • 专业网站设计专家四川企业网站模板步骤
  • 做家政网站上海公司注册地址可以是住宅吗
  • 海外建站流程做电影网站最牛的站长是谁
  • 招商网站建设优势国家免费技能培训
  • 上海协会网站建设无锡网站优化哪家快
  • 小红书推广群天津seo培训
  • html5商业网站开发北大青鸟企业网站制作的市场
  • 佛山做网站的公司wap网
  • 找人开发一个网站多少钱做网站哪种编程语言好