版本比较
题解:P6749 『MdOI R3』Yoshino
正文
增加 7 行删除 7 行
22 行未改动2324252627272829303144 行未改动7677787980808182838437 行未改动12212312412512612612712812913012 行未改动1431441451461471471481491501511521521531541551569 行未改动1661671681691701701711721731748 行未改动18318418518618718718818922 行未改动#define fr first#define se second#define rd read()#define V 30000#define IT set<node>::iterator #define IT set<node>::iterator#define md 998244353using namespace std;static char buf[100000], * pa(buf), * pb(buf);const int block=1000,S=N/block+5;44 行未改动 clear(bl[l]);pushdown(bl[l]); for(int i=l;i<=R[bl[l]];i++) a[i]=v+i-l; init(bl[l]);v+=R[bl[l]]-l+1; for(int i=bl[l]+1;i<bl[r];i++){ tag[i]=v; tag[i]=v; v+=R[i]-L[i]+1; } clear(bl[r]);pushdown(bl[r]); for(int i=L[bl[r]];i<=r;i++) a[i]=v+i-L[bl[r]];37 行未改动 else{ for(int i=l;i<=r;i++){ if(x<=a[i]&&a[i]<=y) res++; } } } return res; } if(tag[bl[l]]){res+=getcnt(l-L[bl[l]]+1,R[bl[l]]-L[bl[l]]+1,x,y,tag[bl[l]]);} else{12 行未改动 } } return res; } }G; }G; struct node{ int l,r,v; node(int L,int R=0,int w=0):l(L),r(R),v(w){}; inline bool operator <(const node &o)const{return l<o.l;} }; }; set<node>s; inline IT split(int pos){ IT it=s.lower_bound(node(pos)); if(it!=s.end()&&it->l==pos) return it;9 行未改动 if(w!=-1) ans-=(G.asksum(1,l-1,w,w+R-L)-G.askcnt(1,l-1,w,w+R-L)*w),ans-=(G.askcnt(R+1,n,w,w+R-L)*(w+R-L)-G.asksum(R+1,n,w,w+R-L)); if(w!=-1) ans-=(G.askcnt(1,l-1,w+R-L+1,V)*(R-L+1)),ans-=(G.askcnt(R+1,n,1,w-1)*(R-L+1)); } s.erase(itl,itr); s.insert(node(l,r,v)); s.insert(node(l,r,v)); ans+=(G.asksum(1,l-1,v,v+r-l)-G.askcnt(1,l-1,v,v+r-l)*v)+(-G.asksum(r+1,n,v,v+r-l)+G.askcnt(r+1,n,v,v+r-l)*(v+r-l)); ans+=(G.askcnt(1,l-1,v+r-l+1,V)*(r-l+1));ans+=(G.askcnt(r+1,n,1,v-1)*(r-l+1)); G.modify(l,r,v); }8 行未改动 op=rd; if(op==2) cout<<ct.ans<<'\n'; else l=rd,r=rd,v=rd,ct.assign(l,r,v); } return 0; return 0;}```