21820_Core

2022-5-16 18:20| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505876582300-Problem List-采集的数据-后羿采集器.html

Pro.ID

21820

Title

Core

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21820

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65535 K (Java/Others)
  • 描述

    Suppose T = < V, E, W > is an acyclic, connected, undirected graph (or we can call it unrooted tree), each edge has a positive weigh, we call this graph Tree Network. (V is the vertex set, E is edge set, and W is weigh set).

    In the Tree Network, each pair of vertex u, v has a simple path, then the distance from u to v, written as d(u, v), is the length of a u, v-path.

    Another definition is d(V, x), d(V, x) = min{ d(v, x) | vV }.

    Suppose any connected subgraph of T is T'=(V', E', W'), We called ECC(T', T) = max{ d(V',u) | u∈(V-V') } is the eccentricity of T'.

    Now is your turn, give you a Tree Network T and a non-negative integer S, you must find a connected subgraph of T —— T', which satisfy the sum all of the edges weigh in T' is not bigger than S and the eccentricity of T' is the least than other subgraph of T. We called the T' "Core of Tree Network"

    Notice: Sometimes, T' only contains one vertex, and you may find there are many cores. But we only want to know the minimal eccentricity of T', and that is determinately.

    输入

    Input includes multiple cases.

    First line is the number of case x.

    For each case:

    The first line includes two integer numbers. N ( 1 ≤ N ≤ 10000 ) and S ( 1 ≤ S ≤ 108 ).

    The other n-1 lines describe the edges in T.

    Each line contains three positive integer numbers u, v, w ( 1 ≤ u, v, w ≤ 10000 ), describe the head, the endpoints and the weigh of an edge.

    输出

    Description

    Suppose T = < V, E, W > is an acyclic, connected, undirected graph (or we can call it unrooted tree), each edge has a positive weigh, we call this graph Tree Network. (V is the vertex set, E is edge set, and W is weigh set).

    In the Tree Network, each pair of vertex u, v has a simple path, then the distance from u to v, written as d(u, v), is the length of a u, v-path.

    Another definition is d(V, x), d(V, x) = min{ d(v, x) | vV }.

    Suppose any connected subgraph of T is T'=(V', E', W'), We called ECC(T', T) = max{ d(V',u) | u∈(V-V') } is the eccentricity of T'.

    Now is your turn, give you a Tree Network T and a non-negative integer S, you must find a connected subgraph of T —— T', which satisfy the sum all of the edges weigh in T' is not bigger than S and the eccentricity of T' is the least than other subgraph of T. We called the T' "Core of Tree Network"

    Notice: Sometimes, T' only contains one vertex, and you may find there are many cores. But we only want to know the minimal eccentricity of T', and that is determinately.

    Input

    Input includes multiple cases.

    First line is the number of case x.

    For each case:

    The first line includes two integer numbers. N ( 1 ≤ N ≤ 10000 ) and S ( 1 ≤ S ≤ 108 ).

    The other n-1 lines describe the edges in T.

    Each line contains three positive integer numbers u, v, w ( 1 ≤ u, v, w ≤ 10000 ), describe the head, the endpoints and the weigh of an edge.

    Output

    Only one integer s, the minimal eccentricity of T'.

    Sample Input

    2
    8 6
    1 3 2
    2 3 2
    3 4 6
    4 5 3
    4 6 4
    4 7 2
    7 8 3
    5 9
    1 2 5
    2 3 2
    2 4 4
    2 5 3

    Sample Output

    5
    3

    Source

    样例输入

    2
    8 6
    1 3 2
    2 3 2
    3 4 6
    4 5 3
    4 6 4
    4 7 2
    7 8 3
    5 9
    1 2 5
    2 3 2
    2 4 4
    2 5 3

    样例输出

    5
    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部