码迷,mamicode.com
首页 > 其他好文 > 详细

yjb

时间:2018-12-21 22:41:08      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:char   play   har   fine   oid   ace   lin   lse   include   

#include<bits/stdc++.h>
#define ls son[rt][0]
#define rs son[rt][1]
using namespace std;
const int N=1e5+20;
int n,tot,root;
int L,R;
struct Splay
{
int siz[N],w[N],f[N],tad[N],tfz[N],son[N][2];
inline void mup(int rt)
{
siz[rt]=1;
if(ls>0) siz[rt]+=siz[ls];
if(rs>0) siz[rt]+=siz[rs];
}
inline int mbuild(int rt,int l,int r)
{
tot++;
siz[tot]=1;
w[tot]=l;
if(l==r) return tot;
int mid=(l+r)>>1;
son[rt][0]=mbuild(ls,l,mid);
son[rt][1]=mbuild(rs,mid+1,r);
mup(rt);
}
inline int mfind(int rt,int x)
{
if(x<=siz[ls]) return mfind(ls,x);
else if(x==siz[ls]+1) return f[rt];
else return mfind(rs,x-siz[ls]-1);
}
inline int mfind2(int rt,int ff)
{
if(ff>=f[rt]) return rt;

}
};
Splay s;
inline void mread(int &rx)
{
int fx=1;char c=getchar();
rx=0;
while(c<48||c>57)
{
if(c==‘-‘) fx=-1;
c=getchar();
}
while(c>=48&&c<=57)
{
rx=rx*10+c-48;
c=getchar();
}
rx*=fx;
}
inline void mtrans()
{
int bf,gw;
if(R<=n-2)
{
bf=s.mfind(root,R);
gw=s.mfind2(root,bf+1);
}
}
int main()
{
int i,j;
mread(n);
root=s.mbuild(1,1,n);
for(i=1;i<=n;i++)
{
mread(L);mread(R);
mtrans();
}
}

yjb

标签:char   play   har   fine   oid   ace   lin   lse   include   

原文地址:https://www.cnblogs.com/spacevortex/p/10159003.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!