Esempio n. 1
0
int main()
{
 
	int i;
	for (i=3;i>=1;i--)
	T.insert(T.root,i);
	T.print(T.root);
	for (i=3;i>=1;i--)
	{
        T.remove(T.root,i);
		T.print(T.root);		
	}
	system("pause");
	return 0;
}
int main(){

    int i,j,k,l,test,t=1,val;

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    scanf("%d",&test);

    while(test--){

        scanf("%s",type);

        //printf("%s\n",type);

        if(type[0]=='I'){
            scanf("%d",&val);
            tree.insert(val);
        }

        if(type[0]=='D'){
            scanf("%d",&val);
            tree.erase(val);
        }

        if(type[0]=='N'){
            scanf("%d %d",&k,&l);
            printf("%d\n",find_min(k+1,l+1));
        }

        if(type[0]=='X'){
            scanf("%d %d",&k,&l);
            printf("%d\n",find_max(k+1,l+1));
        }

    }

    return 0;
}
 void connect(node*a,node*b){
     down(a);
     *(&trp.ns[0]+(a-&ns[0]))=treap::node(a-&ns[0],min(a->virmi,a->mi),max(a->virmx,a->mx),a->virsum+a->sum,a->virsiz+a->siz);
     trp.insert(b->vir,&trp.ns[0]+(a-&ns[0]));
 }