-
Notifications
You must be signed in to change notification settings - Fork 2
/
HDU-hangzhou-1002.cpp
66 lines (61 loc) · 1.17 KB
/
HDU-hangzhou-1002.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
ID: mfs6174
email: mfs6174@gmail.com
PROG: ti
LANG: C++
*/
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
#include<set>
#define sf scanf
#define pf printf
#define llg long long
using namespace std;
//ifstream inf("ti.in");
//ofstream ouf("ti.out");
const int maxlongint=2147483647;
int i,j,k,t,n,m,nn;
int d[120][120],dd[120][120];
int ff[30][120];
int main()
{
freopen("ti.in","r",stdin);
while (sf("%d",&n,&m,&nn)!=EOF)
{
if (n==0&&m==0&&nn==0)
break;
memset(dd,0,sizeof(dd));
for (i=0;i<=n;i++)
for (j=0;j<=n;j++)
if (i!=j)
dd[i][j]=maxlongint;
for (i=1;i<=m;i++)
{
sf("%d%d%d",&j,&k,&t);
if (j==k)
continue;
dd[j][k]=min(dd[j][k],t);
dd[k][j]=dd[j][k];
}
for (k=0;k<=n;k++)
for (i=0;i<=n;i++)
for (j=0;j<=n;j++)
{
if (dd[i][k]==maxlongint||dd[k][j]==maxlongint)
continue;
dd[i][j]=min(dd[i][j],dd[i][k]+dd[k][j]);
}
t=0;
for (j=1;j<=n;j++)
{
t+