(int u, int fa, int edge, int sum, int limit)
| 88 | } |
| 89 | |
| 90 | public static void dfs(int u, int fa, int edge, int sum, int limit) { |
| 91 | curLen = Math.max(curLen, edge); |
| 92 | if (sum > curVal[edge]) { |
| 93 | curVal[edge] = sum; |
| 94 | curNode[edge] = u; |
| 95 | } |
| 96 | for (int e = head[u]; e > 0; e = nxt[e]) { |
| 97 | int v = to[e]; |
| 98 | int w = weight[e]; |
| 99 | if (v != fa && !vis[v]) { |
| 100 | dfs(v, u, edge + 1, sum + (w >= limit ? 1 : -1), limit); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | public static boolean check(int u, int limit) { |
| 106 | preVal[0] = 0; |