CF827D.Best Edge Weight

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a connected weighted graph with nn vertices and mm edges. The graph doesn't contain loops nor multiple edges. Consider some edge with id ii . Let's determine for this edge the maximum integer weight we can give to it so that it is contained in all minimum spanning trees of the graph if we don't change the other weights.

You are to determine this maximum weight described above for each edge. You should calculate the answer for each edge independently, it means there can't be two edges with changed weights at the same time.

输入格式

The first line contains two integers nn and mm ( 2<=n<=21052<=n<=2·10^{5} , n1<=m<=2105n-1<=m<=2·10^{5} ), where nn and mm are the number of vertices and the number of edges in the graph, respectively.

Each of the next mm lines contains three integers uu , vv and cc ( 1<=v,u<=n1<=v,u<=n , vuv≠u , 1<=c<=1091<=c<=10^{9} ) meaning that there is an edge between vertices uu and vv with weight cc .

输出格式

Print the answer for each edge in the order the edges are given in the input. If an edge is contained in every minimum spanning tree with any weight, print -1 as the answer.

输入输出样例

  • 输入#1

    4 4
    1 2 2
    2 3 2
    3 4 2
    4 1 3
    

    输出#1

    2 2 2 1 
  • 输入#2

    4 3
    1 2 2
    2 3 2
    3 4 2
    

    输出#2

    -1 -1 -1 
首页