LuoguP1456 Monkey King (左偏树 Unfinished)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define R(a,b,c) for(register int  a = (b); a <= (c); ++ a)
#define nR(a,b,c) for(register int  a = (b); a >= (c); -- a)
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Fill(a,b) memset(a, b, sizeof(a))
#define ll long long
#define ON_DEBUG

#ifdef ON_DEBUG

#define D_e_Line printf("\n\n----------\n\n")

#else

#define D_e_Line ;

#endif

struct ios{
    template<typename ATP>ios& operator >> (ATP &x){
        x = 0; int f = 1; char c;
        for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-')  f = -1;
        while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
        x*= f;
        return *this;
    }
}io;
using namespace std;

const int N = 100007;

struct LeftTree{
    int l,r,val,dis;
}t[N];
int fa[N];
inline int Find(int x){
    return x == fa[x] ? x : fa[x] = Find(fa[x]);
}

int main(){
    int n,m;
    while(~scanf("%d", &n)){
        
        R(i,1,n){
            t[i].l = t[i].r = t[i].dis = 0;
            io >> t[i].val;
            fa[i] = i;
        }
        
        io >> m;
        
        while(m--){
            int x,y;
            io >> x >> y;
            x = Find(x), y = Find(y);
            if(x == y){
                printf("-1\n"); continue;
            }
            
            p
        }
        
    }
    
    return 0;
}
上一篇:叶胜超:V SYSTEMS(VSYS)--人人可发币的公链项目!


下一篇:King 【POJ - 1364】【差分约束+SPFA+卡了判负环的进队次数】