博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 11992,。。。伪-二维线段树
阅读量:4550 次
发布时间:2019-06-08

本文共 1587 字,大约阅读时间需要 5 分钟。

题目

看白书写的,

数据范围是最多20行嘛
所谓二维,开很多行的一维然后线性加起来,,,

#include
#include
#include
#include
using namespace std;const int N=233333;const int INF=1000000000;//9个9 int n,m,q,SUM,MIN,MAX,x1,x2,y1,y2,ask,x;struct tree{ int sum[N],ma[N],mi[N],set[N],add[N]; void maintain(int t,int L,int R){ int lc=t<<1,rc=lc+1; if (L
=0){ mi[t]=ma[t]=set[t]; sum[t]=set[t]*(R-L+1); } if (add[t]){ mi[t]+=add[t]; ma[t]+=add[t]; sum[t]+=add[t]*(R-L+1); } } void down(int t){ if (add[t]==0&&set[t]==-1)return ; int lc=t<<1,rc=lc+1; if (set[t]>=0){ set[lc]=set[rc]=set[t]; add[lc]=add[rc]=0; set[t]=-1; } if (add[t]){ add[lc]+=add[t]; add[rc]+=add[t]; add[t]=0; } } void update(int t,int L,int R,int x){ if (y1<=L&&R<=y2){ if (ask==1)add[t]+=x; else {
set[t]=x;add[t]=0;} }else{ down(t); int lc=t<<1,rc=lc+1,mid=L+(R-L)/2; if (y1<=mid)update(lc,L,mid,x);else maintain(lc,L,mid); if (mid
=0){ int w=set[t]+ad+add[t]; SUM+=w*(min(R,y2)-max(L,y1)+1); MIN=min(MIN,w); MAX=max(MAX,w); } else if (y1<=L&&R<=y2){ SUM+=sum[t]+(R-L+1)*ad; MIN=min(MIN, mi[t]+ad); MAX=max(MAX, ma[t]+ad); } else { int mid=L+(R-L)/2,lc=t<<1,rc=lc+1; if (y1<=mid)query(lc,L,mid,add[t]+ad); if (mid

转载于:https://www.cnblogs.com/cww97/p/7534024.html

你可能感兴趣的文章
[转]高颜值、好用、易扩展的微信小程序 UI 库,Powered by 有赞
查看>>
[转]SQL Server如何启用xp_cmdshell组件
查看>>
[转]微擎应用笔记3--manifest.xml文件使用说明
查看>>
Codeforces 1000C Covered Points Count 【前缀和优化】
查看>>
python高效读取文件、文件改写
查看>>
gulp
查看>>
pgsql查询优化之模糊查询
查看>>
[转]-Gradle使用手册(三):构建任务
查看>>
ExtJS下拉树
查看>>
android 调用系统相机录像并保存
查看>>
BW系统表的命名规则
查看>>
Asp.Net在IE10下出现_doPostBack未定义的解决办法 LinkButton
查看>>
《CLR via C#》Part2之Chapter5 基元类型、引用类型和值类型(一)
查看>>
接口和抽象类的对比,面向对象的三大特性和四大特性
查看>>
1-9 RHEL7-文件权限管理
查看>>
apache服务器安装
查看>>
Search a 2D Matrix
查看>>
文件解析漏洞
查看>>
弹性成像的一些术语
查看>>
ListBox 消息 (zz)
查看>>