Method
dfs2
(int cur, int fa, int di, int tr)
Source from the content-addressed store, hash-verified
| 139 | |
| 140 | // 收集信息迭代版 |
| 141 | public static void dfs2(int cur, int fa, int di, int tr) { |
| 142 | stacksize = 0; |
| 143 | push(cur, fa, di, tr, -1); |
| 144 | while (stacksize > 0) { |
| 145 | pop(); |
| 146 | if (e == -1) { |
| 147 | tree[u] = t; |
| 148 | dist[u] = d; |
| 149 | e = head[u]; |
| 150 | } else { |
| 151 | e = nxt[e]; |
| 152 | } |
| 153 | if (e != 0) { |
| 154 | push(u, f, d, t, e); |
| 155 | int v = to[e]; |
| 156 | if (v != f) { |
| 157 | push(v, u, d + weight[e], t, -1); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | public static int compute() { |
| 164 | int ans = 1000000001; |
Tested by
no test coverage detected