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