版本比较
题解:P14521 【MX-S11-T2】加减乘除
正文
增加 5 行删除 5 行
25 行未改动26272829303031323334343536373815 行未改动5455565758585960616228 行未改动91929394959596979798991001016 行未改动25 行未改动#define int long longusing namespace std;const int N=1e6+5,inf=1e18;int n,q,head[N],m,dif[N<<2],ask[N];struct Edge{int from,to,l,r,nxt;}e[N]; struct Edge{int from,to,l,r,nxt;}e[N];struct Node{char op;int dt;}a[N];struct Range{int l,r;}lim[N],pos[N];//lim[i]表示 "能走到 i号点的数的范围"//pos[i]表示 "能走到 i号点的数的原始范围,即在根节点处的范围" //pos[i]表示 "能走到 i号点的数的原始范围,即在根节点处的范围"inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||'9'<ch){if(ch=='-')f=0;ch=getchar();}15 行未改动 pos[v].l=max(el,calc(pos[u].l,a[u])); pos[v].r=min(er,calc(pos[u].r,a[u])); lim[v].l=pos[v].l-offest; lim[v].r=pos[v].r-offest; //求解 pos数组 和 lim数组 //求解 pos数组 和 lim数组 dfs(v,calc(offest,a[v])); }}void Discretization()//离散化28 行未改动 head[p]=i-1; } for(int i=1;i<=n;i++) a[i].op=getchar(),a[i].dt=read(); lim[1]=pos[1]=(Range){-inf,inf};//根节点什么数都可以 lim[1]=pos[1]=(Range){-inf,inf};//根节点什么数都可以 dfs(1,calc(0,a[1])); for(int i=1;i<=n;i++)//特判掉无论如何走不到的点 for(int i=1;i<=n;i++)//特判掉无论如何走不到的点 lim[i].r=max(lim[i].r,lim[i].l-1); for(int i=1;i<=q;i++) ask[i]=read(); Discretization();6 行未改动