(int x)
| 101 | } |
| 102 | |
| 103 | public static void splay(int x) { |
| 104 | int siz = 0; |
| 105 | sta[++siz] = x; |
| 106 | for (int y = x; !isroot(y); y = fa[y]) { |
| 107 | sta[++siz] = fa[y]; |
| 108 | } |
| 109 | while (siz != 0) { |
| 110 | down(sta[siz--]); |
| 111 | } |
| 112 | while (!isroot(x)) { |
| 113 | int f = fa[x]; |
| 114 | if (!isroot(f)) { |
| 115 | if (lr(x) == lr(f)) { |
| 116 | rotate(f); |
| 117 | } else { |
| 118 | rotate(x); |
| 119 | } |
| 120 | } |
| 121 | rotate(x); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | public static void access(int x) { |
| 126 | for (int y = 0; x != 0; y = x, x = fa[x]) { |