22485_ABitDifferen

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

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

Pro.ID

22485

Title

A Bit Different

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    MST (Minimum Spanning Tree) is a common problem in graph theory. It is too easy for all of you. Now there is a problem a bit different.

    Given a weighted graph G(V, E), if T is a spanning trees of G.

    Define value(T) = max{ value(e) | e is in T } - min{ value(e) | e is in T }

    In this problem, you only have to output the minimum value(T).

    输入

    The first line of the input is a positive integer C, denoting the number of test cases followed.

    The first line of each test case is two positive integers N ( 2 < N ≤ 200 ) and M ( M ≤ 5000 ), which represent the number of vertices and edges of G. After that, there are M lines followed. The i-th ( 1 ≤ iM ) line contains three integers Xi ( 0 < XiN ), Yi ( 0 ≤ YiN ), Di ( 0 < Di ≤ 108 ), which means that there is an edge from Xi to Yi and the distance of this edge is Di. You can assume that the graph G is connected and no more than one edge exists between any two vertices.

    输出

    Description

    MST (Minimum Spanning Tree) is a common problem in graph theory. It is too easy for all of you. Now there is a problem a bit different.

    Given a weighted graph G(V, E), if T is a spanning trees of G.

    Define value(T) = max{ value(e) | e is in T } - min{ value(e) | e is in T }

    In this problem, you only have to output the minimum value(T).

    Input

    The first line of the input is a positive integer C, denoting the number of test cases followed.

    The first line of each test case is two positive integers N ( 2 < N ≤ 200 ) and M ( M ≤ 5000 ), which represent the number of vertices and edges of G. After that, there are M lines followed. The i-th ( 1 ≤ iM ) line contains three integers Xi ( 0 < XiN ), Yi ( 0 ≤ YiN ), Di ( 0 < Di ≤ 108 ), which means that there is an edge from Xi to Yi and the distance of this edge is Di. You can assume that the graph G is connected and no more than one edge exists between any two vertices.

    Output

    The output should consists of C lines, one line for each test case, only containing one integer which represents the minimum value of value( T ). No redundant spaces are needed.

    Sample Input

    1
    3 3
    1 2 10
    1 3 20
    2 3 30

    Sample Output

    10

    Source

    样例输入

    1
    3 3
    1 2 10
    1 3 20
    2 3 30

    样例输出

    10

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部