正文
增加 5 行删除 5 行
25 行未改动2627282930313233343536373815 行未改动54555657585960616228 行未改动9192939495969798991001016 行未改动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 Node{char op;int dt;}a[N];struct Range{int l,r;}lim[N],pos[N];//lim[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数组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};//根节点什么数都可以dfs(1,calc(0,a[1]));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 行未改动25 行未改动2627282930313233343536373815 行未改动54555657585960616228 行未改动9192939495969798991001016 行未改动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 Node{char op;int dt;}a[N];struct Range{int l,r;}lim[N],pos[N];//lim[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数组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};//根节点什么数都可以dfs(1,calc(0,a[1]));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 行未改动