| 146 | } |
| 147 | |
| 148 | public static void dfs4(int cur, int tag) { |
| 149 | stacksize = 0; |
| 150 | push(cur, 0, 0, tag, -1); |
| 151 | while (stacksize > 0) { |
| 152 | pop(); |
| 153 | if (e == -1) { |
| 154 | top[u] = b; |
| 155 | if (son[u] == 0) { |
| 156 | continue; |
| 157 | } |
| 158 | push(u, 0, 0, b, -2); |
| 159 | push(son[u], 0, 0, b, -1); |
| 160 | continue; |
| 161 | } else if (e == -2) { |
| 162 | e = head[u]; |
| 163 | } else { |
| 164 | e = nxt[e]; |
| 165 | } |
| 166 | if (e != 0) { |
| 167 | push(u, 0, 0, b, e); |
| 168 | int v = to[e]; |
| 169 | if (v != fa[u] && v != son[u]) { |
| 170 | push(v, 0, 0, v, -1); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | public static int getLca(int a, int b) { |
| 177 | while (top[a] != top[b]) { |