(int root)
| 79 | } |
| 80 | |
| 81 | public static void dfs1(int root) { |
| 82 | stackSize = 0; |
| 83 | push(root, 0, -1); |
| 84 | while (stackSize > 0) { |
| 85 | pop(); |
| 86 | if (e == -1) { |
| 87 | deep[u] = deep[f] + 1; |
| 88 | stjump[u][0] = f; |
| 89 | for (int p = 1; p <= power; p++) { |
| 90 | stjump[u][p] = stjump[stjump[u][p - 1]][p - 1]; |
| 91 | } |
| 92 | e = head[u]; |
| 93 | } else { |
| 94 | e = next[e]; |
| 95 | } |
| 96 | if (e != 0) { |
| 97 | push(u, f, e); |
| 98 | if (to[e] != f) { |
| 99 | push(to[e], u, -1); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | public static int lca(int a, int b) { |
| 106 | if (deep[a] < deep[b]) { |