当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6933:PepperLa's Cram School

题目描述
PepperLa is good at dealing with string problems, so he's going to offer string algorithm courses.

PepperLa has set up $N$ class rooms, there's one road between every two class rooms, and each road is equal in length.

PepperLa is afraid of the dark, so he only walks on roads with the light on. At the beginning, there is no light on. PepperLa has to pay one dollar for lighting the light of a road. However, PepperLa is dreaming of buying himself a switch, so he would like to pay the least.

The courses are scheduled so tightly that PepperLa can't afford to waste his time. So the distance between two class room should not be too far away. Specifically, you need to light the fewest roads so that the shortest path between class room $i$ and class room $j$ should eaqual to $dis[i][j]$.

Please tell PeoperLa how much is the minimum he has to pay.
输入解释
There are multiple test cases in this problem.

For every test case, The first line has 1 interger, $N(1 \leq N \leq 10^3)$

The next $N$ lines each line contains $N$ interger, the interger in $i$'th row, $j$'th column is $dis[i][j](1 \leq dis[i][j] \leq 10^6)$

The input guarantees that the data given is legal and there's always a solution

$dis[i][j]=dis[j][i],dis[i][i]=0, \sum{N}\leq 5 \times 10^3$
输出解释
For each test case, output a single line contains one integer,representing for the minimal money PepperLa has to pay.
输入样例
3
0 1 2
1 0 1
2 1 0
输出样例
2
提示
Light the light of road (1,2),(2,3)
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6933

最后修改于 2021-06-22T18:18:58+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1500MS(Java/Others) 65536/65536K(Java/Others)