Railway has always been the most popular mean of transport in Byteotia. Out of N towns in the land, M pairs are connected by track segments belonging to Byteotian State Railways (BSR). The tracks do not cross outside of towns, and may lead through picturesque bridges and somewhat less picturesque tunnels. The ticket for travelling between any two towns directly connected by rail costs a bythalers.
Currently the transportation market in Byteotia is changing. As of now, BSR faces a new competitor: Byteotian Airlines (BA). BA plans to operate flights between some pairs of towns. Since Byteotian railways are quite comfortable, the BA board has decided to operate flights only between pairs of towns that are not directly connected by rail. Due to economy, BA will fly only between towns for which the cheapest railway connection requires exactly one change. The ticket for each such flight is going to cost b bythalers.
To help Byteotian citizens in planning their trips, the Byteotian Ministry for Transport (BMT) has decided to issue leaflets specifying the cheapest routes between all possible towns. A sequence of an arbitrary number of direct railway or airplane connections is called a route. A BMT officer by the name of Byteasar has been commissioned with the task of preparing the price list for the leaflets. Could you help him in writing a program that will determine the right prices?
Let us clarify that all the connections in Byteotia, both by railway and airplane, are bidirectional.
一个n个点m条边的无向联通图,每条边的权值都是a。
定义当前图的i与j最短距离为dis[i][j]。
现在改造这个图:对于任何满足dis[u][v]=2a的(u,v),在u与v之间连一条权值为b的无向边
原来的权值为a的边保留