1 条题解
-
0Guest LV 0 MOD
-
0
尚未完成,实在不想搞了。
#include<bits/stdc++.h> #define LL long long const LL maxn=1e5; inline const void read(LL &a) { a=0; char c=getchar(); while(c<'0'||c>'9')c=getchar(); while(c>='0'&&c<='9') { a=(a<<1)+(a<<3)+c-'0'; c=getchar(); } } inline const void write(LL a) { if(a>9)write(a/10); putchar(a%10+'0'); } inline const LL max(LL a,LL b) { if(a>b)return a; return b; } LL n,m; LL height[maxn<<2],lh[maxn<<2],rh[maxn<<2],lloc[maxn<<2],rloc[maxn<<2]; inline const void update(LL p) { height[p]=max(height[p<<1],height[p<<1|1]); } inline const void build(LL p,LL l,LL r) { if(l==r){read(height[p]);return ;} LL mid=(l+r)>>1; build(p<<1,l,mid); build(p<<1|1,mid+1,r); update(p); } inline const void push_col(LL p,LL l,LL r) { if(lh[p]||rh[p]) { LL mid=(l+r)>>1; push_col(p<<1,l,mid);push_col(p<<1|1,mid+1,r); lh[p<<1]=lh[p<<1|1]=lh[p];rh[p<<1]=rh[p<<1|1]=rh[p]; lloc[p<<1]=lloc[p<<1|1]=lloc[p];rloc[p<<1]=rloc[p<<1|1]=rloc[p]; if(lh[p]==rh[p])height[p<<1]=height[p<<1|1]=height[p]; else { double k=double(rh[p]-lh[p])/double(rloc[p]-lloc[p]),b=double(rh[p])-k*double(rloc[p]); LL minus=(LL)(max(double(l)*k+b,double(r)*k/+b)); height[p<<1]=height[p]-minus+(LL)(max(double(l)*k+b,double(mid)*k/+b)); height[p<<1|1]=height[p]-minus+(LL)(max(double(mid+1)*k+b,double(r)*k+b)); } lh[p]=rh[p]=lloc[p]=rloc[p]=0; } } inline const LL query(LL p,LL l,LL r,LL ll,LL rr) { if(l>=ll&&r<=rr)return height[p]; push_col(p,l,r); LL mid=(l+r)>>1,ans=0; if(mid>=ll)ans=max(ans,query(p<<1,l,mid,ll,rr)); if(mid+1<=rr)ans=max(ans,query(p<<1|1,mid+1,r,ll,rr)); return ans; } inline const void modify(LL p,LL l,LL r,LL ll,LL rr,LL lup,LL rup) { push_col(p,l,r); if(l>=ll&&r<=rr) { push_col(p,l,r); lloc[p]=ll;rloc[p]=rr;lh[p]=lup;rh[p]=rup; if(lh[p]==rh[p])height[p]=height[p]+rh[p]; else { double k=double(rh[p]-lh[p])/double(rloc[p]-lloc[p]),b=double(rh[p])-k*double(rloc[p]); height[p]=height[p]+(LL)(max(double(l)*k+b,double(r)*k/+b)); } return ; } LL mid=(l+r)>>1; if(mid>=ll)modify(p<<1,l,mid,ll,rr,lup,rup); if(mid+1<=rr)modify(p<<1|1,mid+1,r,ll,rr,lup,rup); update(p); } int main() { read(n); build(1,1,n); read(m); long long t,x,y,z,left; while(m) { read(t); if(t==1) { read(x);read(y);read(left); modify(1,1,n,left,left+x-1,y,y); } if(t==2) { read(x);read(y);read(left); modify(1,1,n,left,left+(y>>1),0,y); modify(1,1,n,left+(x>>1),left+(x>>1),-y,-y); modify(1,1,n,left+(x>>1),left+x-1,y,0); } if(t==3) { read(x);read(y);read(z);read(left); modify(); modify(); } if(t==4) { read(x);read(y); write(query(1,1,n,x,y));printf("\n"); } m--; } return 0; }
- 1
信息
- 难度
- 10
- 分类
- (无)
- 标签
- (无)
- 递交数
- 4
- 已通过
- 0
- 通过率
- 0%
- 上传者