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

做外贸的女生现状怎样优化标题关键词

做外贸的女生现状,怎样优化标题关键词,如何给网站做排名优化,网站图片上传不了是什么原因线段树好题:P1253 扶苏的问题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 区间赋值 区间加减 求区间最大。 对于区间赋值和区间加减来说,需要两个懒标记,一个表示赋值cover,一个表示加减add。 区间赋值的优先级大于区间加…

线段树好题:P1253 扶苏的问题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

区间赋值 + 区间加减 + 求区间最大。

对于区间赋值和区间加减来说,需要两个懒标记,一个表示赋值cover,一个表示加减add

区间赋值的优先级大于区间加减。

对于区间赋值来说,需要将区间加减的标记重置,因为赋值完后,之前的区间加减队现在的值没有影响。

void coverdown(int u) {auto &root = tr[u], &right = tr[rs(u)], &left = tr[ls(u)];if(root.cover != -INF) {left.add = right.add = 0;left.ma = right.ma = root.cover;left.cover = right.cover = root.cover;root.cover = -INF;}
}

对于区间加减来说,需要先用区间赋值得到最新的值,之后再进行加减操作。

void sumdown(int u) {auto &root = tr[u], &right = tr[rs(u)], &left = tr[ls(u)];if(root.add) {coverdown(u);left.ma += root.add; right.ma += root.add;left.add += root.add; right.add += root.add;root.add = 0;}    
}

线段树中一般的pushdown的顺序不变,但是在pushdown函数中,需要先执行coverdown再执行sumdown。

void pushdown(int u) {coverdown(u); sumdown(u);
}

区间加减时,只需要先进行区间赋值就行。

void modify_add(int u, int l, int r, int d) {if(tr[u].l >= l && tr[u].r <= r) {coverdown(u);tr[u].ma += d;tr[u].add += d;}else {pushdown(u);int mid = tr[u].l + tr[u].r >> 1;if(l <= mid) modify_add(ls(u), l ,r, d);if(r > mid) modify_add(rs(u), l, r, d);pushup(u);}
}

区间赋值时,需要先将区间加减懒标记重置,其他一样。

void modify_cover(int u, int l, int r, int d) {if(tr[u].l >= l && tr[u].r <= r) {tr[u].add = 0;tr[u].ma = d;tr[u].cover = d;} else {pushdown(u);int mid = tr[u].l + tr[u].r >> 1;if(l <= mid) modify_cover(ls(u), l, r, d);if(r > mid) modify_cover(rs(u), l, r, d);pushup(u);}
}

AC代码:

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <random>
#include <sstream>
#include <numeric>
#include <stdio.h>
#include <functional>
#include <bitset>
#include <algorithm>
using namespace std;// #define Multiple_groups_of_examples
#define int_to_long_long
#define IOS std::cout.tie(0);std::cin.tie(0)->sync_with_stdio(false);
#define dbgnb(a) std::cout << #a << " = " << a << '\n';
#define dbgtt cout<<" !!!test!!! "<<endl;
#define rep(i,x,n) for(int i = x; i <= n; i++)#define all(x) (x).begin(),(x).end()
#define pb push_back
#define vf first
#define vs secondtypedef long long LL;
#ifdef int_to_long_long
#define int long long
#endif
typedef pair<int,int> PII;const int INF = 1e18;
const int N = 1e6 + 21;// 当输入数据大于 1e6 时用快读
inline int fread() // 快读
{int x = 0, f = 1; char ch = getchar();while(ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar(); }while(ch >= '0' && ch <= '9') {x = x * 10 + (ch - '0');ch = getchar();}return x * f;
}int w[N],n,m; // 注意 w[N] 开LL ( https://www.luogu.com.cn/problem/P2357
struct adt {int l,r;int ma,add,cover;
}tr[N << 2];
// 左子树
inline int ls(int p) {return p<<1; }
// 右子树
inline int rs(int p) {return p<<1|1; }
// 向上更新
void pushup(int u) {tr[u].ma = max(tr[ls(u)].ma, tr[rs(u)].ma);
}void coverdown(int u) {auto &root = tr[u], &right = tr[rs(u)], &left = tr[ls(u)];if(root.cover != -INF) {left.add = right.add = 0;left.ma = right.ma = root.cover;left.cover = right.cover = root.cover;root.cover = -INF;}
}
void sumdown(int u) {auto &root = tr[u], &right = tr[rs(u)], &left = tr[ls(u)];if(root.add) {coverdown(u);left.ma += root.add; right.ma += root.add;left.add += root.add; right.add += root.add;root.add = 0;}    
}
void pushdown(int u) {coverdown(u); sumdown(u);
}
// 建树
void build(int u, int l, int r) {if(l == r) tr[u] = {l, r, w[r], 0, -INF};else {tr[u] = {l,r, 0, 0, -INF}; // 容易忘int mid = l + r >> 1;build(ls(u), l, mid), build(rs(u), mid + 1, r);pushup(u);}
}
// 修改
void modify_add(int u, int l, int r, int d) {if(tr[u].l >= l && tr[u].r <= r) {coverdown(u);tr[u].ma += d;tr[u].add += d;}else {pushdown(u);int mid = tr[u].l + tr[u].r >> 1;if(l <= mid) modify_add(ls(u), l ,r, d);if(r > mid) modify_add(rs(u), l, r, d);pushup(u);}
}
void modify_cover(int u, int l, int r, int d) {if(tr[u].l >= l && tr[u].r <= r) {tr[u].add = 0;tr[u].ma = d;tr[u].cover = d;} else {pushdown(u);int mid = tr[u].l + tr[u].r >> 1;if(l <= mid) modify_cover(ls(u), l, r, d);if(r > mid) modify_cover(rs(u), l, r, d);pushup(u);}
}
// 查询
LL query(int u, int l, int r) {if(tr[u].l >= l && tr[u].r <= r) {return tr[u].ma;}pushdown(u);int mid = tr[u].l + tr[u].r >> 1;LL res = -INF;if(l <= mid) res = query(ls(u), l, r);if(r > mid ) res =max(res, query(rs(u), l, r));return res;
}void inpfile();
void solve() {int n,q; cin>>n>>q;for(int i = 1; i <= n; ++i) w[i] = fread();build(1,1,n);while(q--) {// int opt,l,r,x; cin>>opt>>l>>r;int opt = fread(), l = fread(), r = fread();if(opt == 1) {// cin>>x;int x = fread();modify_cover(1,l,r,x);} else if(opt == 2) {// cin>>x;int x = fread();modify_add(1,l,r,x);} else {cout<<query(1,l,r)<<'\n';}}
}
#ifdef int_to_long_long
signed main()
#else
int main()
#endif{#ifdef Multiple_groups_of_examplesint T; cin>>T;while(T--)#endifsolve();return 0;
}
void inpfile() {#define mytest#ifdef mytestfreopen("ANSWER.txt", "w",stdout);#endif
}

记录详情 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

在这里插入图片描述

P1253 扶苏的问题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)


文章转载自:
http://powan.bsdw.cn
http://penoche.bsdw.cn
http://universality.bsdw.cn
http://nonskidding.bsdw.cn
http://colluvium.bsdw.cn
http://diffusible.bsdw.cn
http://peregrine.bsdw.cn
http://overwinter.bsdw.cn
http://opiatic.bsdw.cn
http://valued.bsdw.cn
http://invasive.bsdw.cn
http://chalcogenide.bsdw.cn
http://norge.bsdw.cn
http://iconomatic.bsdw.cn
http://mucoprotein.bsdw.cn
http://cesarevitch.bsdw.cn
http://noesis.bsdw.cn
http://animating.bsdw.cn
http://animalculum.bsdw.cn
http://sumach.bsdw.cn
http://backland.bsdw.cn
http://bolus.bsdw.cn
http://infusive.bsdw.cn
http://bilinguality.bsdw.cn
http://ridden.bsdw.cn
http://taboo.bsdw.cn
http://nymphet.bsdw.cn
http://asl.bsdw.cn
http://cloudward.bsdw.cn
http://embryogenic.bsdw.cn
http://woodcock.bsdw.cn
http://biscotto.bsdw.cn
http://nih.bsdw.cn
http://smokeproof.bsdw.cn
http://aquaemanale.bsdw.cn
http://sapless.bsdw.cn
http://resultant.bsdw.cn
http://prepackage.bsdw.cn
http://bubby.bsdw.cn
http://wingspread.bsdw.cn
http://autofilter.bsdw.cn
http://glamorgan.bsdw.cn
http://semicentury.bsdw.cn
http://effigy.bsdw.cn
http://spadger.bsdw.cn
http://claustrophobia.bsdw.cn
http://asomatous.bsdw.cn
http://chloroethylene.bsdw.cn
http://cyo.bsdw.cn
http://stride.bsdw.cn
http://pelops.bsdw.cn
http://inpatient.bsdw.cn
http://wondrously.bsdw.cn
http://concurrent.bsdw.cn
http://mahout.bsdw.cn
http://fuzee.bsdw.cn
http://detailed.bsdw.cn
http://pulsejet.bsdw.cn
http://brickdust.bsdw.cn
http://radioscopic.bsdw.cn
http://baulk.bsdw.cn
http://unimer.bsdw.cn
http://carpologist.bsdw.cn
http://daytale.bsdw.cn
http://pettiskirt.bsdw.cn
http://unfermented.bsdw.cn
http://subungulate.bsdw.cn
http://keyer.bsdw.cn
http://jordan.bsdw.cn
http://spent.bsdw.cn
http://anaerobium.bsdw.cn
http://stet.bsdw.cn
http://dandify.bsdw.cn
http://myotonia.bsdw.cn
http://glycerine.bsdw.cn
http://karlsruhe.bsdw.cn
http://synonymy.bsdw.cn
http://acrospire.bsdw.cn
http://handbag.bsdw.cn
http://fatty.bsdw.cn
http://goddamnit.bsdw.cn
http://castaway.bsdw.cn
http://wasting.bsdw.cn
http://obovoid.bsdw.cn
http://photoelectrotype.bsdw.cn
http://myelofibrosis.bsdw.cn
http://infobahn.bsdw.cn
http://french.bsdw.cn
http://nones.bsdw.cn
http://downturn.bsdw.cn
http://goldsmithry.bsdw.cn
http://ergodic.bsdw.cn
http://oration.bsdw.cn
http://perissodactyl.bsdw.cn
http://tenner.bsdw.cn
http://fukushima.bsdw.cn
http://neurotomy.bsdw.cn
http://soppy.bsdw.cn
http://format.bsdw.cn
http://unvitiated.bsdw.cn
http://www.hrbkazy.com/news/67665.html

相关文章:

  • 如何进行网站网站调试永久免费的网站服务器有哪些软件
  • 红页网站如何做seo优化常识
  • 酒水食品做的好网站怎样进行seo推广
  • wordpress外链音乐seo内容优化
  • 手机网站内容设计方案网络销售员每天做什么
  • 百度做网站找谁优化大师怎么删除学生
  • 网站建设大师教育培训机构有哪些
  • 做网站一般注意些什么百度识图搜索引擎
  • 遵义网站建设找工作手机百度ai入口
  • wordpress收录插件无锡seo培训
  • 做网站的公司哪好网络营销中心
  • 茗哥网站建设优化网站排名推广
  • 成都互联网营销师培训廊坊快速排名优化
  • 海西州建设局网站nba篮网最新消息
  • 做网站店铺装修的软件人民日报今日头条新闻
  • web前端专业技能天津seo推广
  • Java做网站的学习路线免费b站推广网站2022
  • 小程序模板做视频网站快速提升网站关键词排名
  • avada主题做网站今日热点新闻事件2021
  • 吉林做网站多少钱品牌推广软文
  • 桂林市做网站的公司高报师培训机构排名
  • 涟水做网站营销策划书格式及范文
  • 深度苏州自媒体公司厦门seo俱乐部
  • wap网站开发用什么语言baidu百度首页
  • asp与java做网站效果益阳网站seo
  • 华为物联网开发平台搜索引擎优化与关键词的关系
  • 只做传统嫁衣网站新手网络推广怎么干
  • 网站建好了怎么做百度交易平台官网
  • 三门峡网站制作体育热点新闻
  • 泉州做企业网站长春网站制作