欢迎光临
我们一直在努力

PLCT检查是什么【bzoj3669】[Noi2014]魔法森林 Kruskal+LCT

#include <cstdio>
#include <algorithm>
#define N 150010
#define lson c[0][x]
#define rson c[1][x]
using namespace std;
struct data
{
	int x , y , b , d;
}a[N];
int fa[N] , c[2][N] , w[N] , maxp[N] , rev[N];
bool cmp(data a , data e)
{
	return a.b < e.b;
}
void pushup(int x)

void pushdown(int x)

}
bool isroot(int x)
{
	return c[0][fa[x]] != x && c[1][fa[x]] != x;
}
void update(int x)

void rotate(int x)

void splay(int x)

		rotate(x);
	}
}
void access(int x)
{
	int t = 0;
	while(x) splay(x) , rson = t , pushup(x) , t = x , x = fa[x];
}
int find(int x)
{
	access(x) , splay(x);
	while(lson) pushdown(x) , x = lson;
	return x;
}
void makeroot(int x)
{
	access(x) , splay(x);
	swap(lson , rson) , rev[x] ^= 1;
}
void link(int x , int y)
{
	makeroot(x) , fa[x] = y;
}
void cut(int x , int y)
{
	makeroot(x) , access(y) , splay(y) , c[0][y] = fa[x] = 0 , pushup(y);
}
void split(int x , int y)
{
	makeroot(y) , access(x) , splay(x);
}
int main()

		if(find(1) == find(n)) split(1 , n) , ans = min(ans , a[i].b + w[maxp[1]]);
	}
	printf("%d
" , ans == 0x7fffffff ? -1 : ans);
	return 0;
}
赞(0)
未经允许不得转载:上海聚慕医疗器械有限公司 » PLCT检查是什么【bzoj3669】[Noi2014]魔法森林 Kruskal+LCT

登录

找回密码

注册