CF416E.President's Path

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Good old Berland has nn cities and mm roads. Each road connects a pair of distinct cities and is bidirectional. Between any pair of cities, there is at most one road. For each road, we know its length.

We also know that the President will soon ride along the Berland roads from city ss to city tt . Naturally, he will choose one of the shortest paths from ss to tt , but nobody can say for sure which path he will choose.

The Minister for Transport is really afraid that the President might get upset by the state of the roads in the country. That is the reason he is planning to repair the roads in the possible President's path.

Making the budget for such an event is not an easy task. For all possible distinct pairs s,ts,t ( s<t ) find the number of roads that lie on at least one shortest path from ss to tt .

输入格式

The first line of the input contains integers n,mn,m ( 2<=n<=5002<=n<=500 , 0<=m<=n(n1)/20<=m<=n·(n-1)/2 ) — the number of cities and roads, correspondingly. Then mm lines follow, containing the road descriptions, one description per line. Each description contains three integers xi,yi,lix_{i},y_{i},l_{i} ( 1<=xi,yi<=n,xiyi,1<=li<=1061<=x_{i},y_{i}<=n,x_{i}≠y_{i},1<=l_{i}<=10^{6} ), where xi,yix_{i},y_{i} are the numbers of the cities connected by the ii -th road and lil_{i} is its length.

输出格式

Print the sequence of integers c12,c13,...,c1n,c23,c24,...,c2n,...,cn1,nc_{12},c_{13},...,c_{1n},c_{23},c_{24},...,c_{2n},...,c_{n-1,n} , where cstc_{st} is the number of roads that can lie on the shortest path from ss to tt . Print the elements of sequence cc in the described order. If the pair of cities ss and tt don't have a path between them, then cst=0c_{st}=0 .

输入输出样例

  • 输入#1

    5 6
    1 2 1
    2 3 1
    3 4 1
    4 1 1
    2 4 2
    4 5 4
    

    输出#1

    1 4 1 2 1 5 6 1 2 1 
首页