| 182 | |
| 183 | // 收集信息迭代版 |
| 184 | public static void dfs2(int cur, int fa, int pmaxv, int pedge) { |
| 185 | stacksize = 0; |
| 186 | push(cur, fa, pmaxv, pedge, -1); |
| 187 | while (stacksize > 0) { |
| 188 | pop(); |
| 189 | if (e == -1) { |
| 190 | if (edge > r) { |
| 191 | continue; |
| 192 | } |
| 193 | maxvArr[++cnta] = maxv; |
| 194 | edgeArr[cnta] = edge; |
| 195 | e = head[u]; |
| 196 | } else { |
| 197 | e = nxt[e]; |
| 198 | } |
| 199 | if (e != 0) { |
| 200 | push(u, f, maxv, edge, e); |
| 201 | int v = to[e]; |
| 202 | if (v != f && !vis[v]) { |
| 203 | push(to[e], u, Math.max(maxv, weight[e]), edge + 1, -1); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | public static long calc(int u, int maxv, int edge) { |
| 210 | cnta = 0; |