F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

PepperLa's Cram School

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 80    Accepted Submission(s): 24


Problem Description
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.
 

Input
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$
 

Output
For each test case, output a single line contains one integer,representing for the minimal money PepperLa has to pay.
 

Sample Input
3 0 1 2 1 0 1 2 1 0
 

Sample Output
2
 

Hint

Light the light of road (1,2),(2,3)
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-26 06:14:10, Gzip enabled