左偏树模板

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<stack>
#include<bitset>
#include<cstring>
#define ll long long
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
using namespace std;
const int INF=0x3f3f3f3f,N=100010;

struct left_tree{
    struct node{
        int rc,lc,v,d;
    }t[N];

    int merge(int x,int y){
        if(!x||!y) return x+y;
        if(t[x].v>t[y].v) swap(x,y);
        t[x].rc=merge(t[x].rc,y);
        if(t[t[x].lc].d<t[t[x].rc].d) swap(t[x].lc,t[x].rc);
        t[x].d=t[t[x].rc].d+1;
        return x;
    }
    
    int pop(int x){return merge(t[x].lc,t[x].rc);}
};

int main(){
    
    return 0;
}
posted @ 2021-04-14 22:15  wsy_jim  阅读(32)  评论(0编辑  收藏  举报