欢迎光临
我们一直在努力

PLCT检查是什么[luoguP2147] [SDOI2008]Cave 洞穴勘测(并查集 || lct)

  1 #include <cstdio>
  2 #include <iostream>
  3 #define N 10001
  4 #define swap(x, y) ((x) ^= (y) ^= (x) ^= (y))
  5 
  6 int n, m;
  7 int f[N], rev[N], son[N][2], s[N], size[N];
  8 
  9 inline int read()
 10 
 17 
 18 inline bool isroot(int x)
 19 {
 20     return son[f[x]][0] ^ x && son[f[x]][1] ^ x;
 21 }
 22 
 23 inline int get(int x)
 24 {
 25     return son[f[x]][1] == x;
 26 }
 27 
 28 inline void pushdown(int x)
 29 
 37 }
 38 
 39 inline void rotate(int x)
 40 
 53 
 54 inline void splay(int x)
 55 
 64 
 65 inline void access(int x)
 66 {
 67     for(int t = 0; x; t = x, x = f[x]) splay(x), son[x][1] = t;
 68 }
 69 
 70 inline void reverse(int x)
 71 {
 72     access(x);
 73     splay(x);
 74     rev[x] ^= 1;
 75 }
 76 
 77 inline int find(int x)
 78 {
 79     access(x);
 80     splay(x);
 81     while(son[x][0]) x = son[x][0];
 82     return x;
 83 }
 84 
 85 inline void link(int x, int y)
 86 {
 87     reverse(x);
 88     f[x] = y;
 89     splay(x);
 90 }
 91 
 92 inline void cut(int x, int y)
 93 {
 94     reverse(x);
 95     access(y);
 96     splay(y);
 97     son[y][0] = f[x] = 0;
 98 }
 99 
100 int main()
101 
115     return 0;
116 }
赞(0)
未经允许不得转载:上海聚慕医疗器械有限公司 » PLCT检查是什么[luoguP2147] [SDOI2008]Cave 洞穴勘测(并查集 || lct)

登录

找回密码

注册