1 #include <iostream>
2 #include <string.h>
3 #include <stdio.h>
4 #include <algorithm>
5 #define inf 0x7fffffff
6 using namespace std;
7 int d[110][110],b[110][110],id;
8 int main (){
9 int n,a,b1,t;
10 cin>>n;
11 for (int i=0;i<=n;i++)
12 for (int j=0;j<=n;j++)
13 if (i==j) d[i][j]=0;
14 else d[i][j]=inf;
15 while(scanf("%d%d%d",&a,&b1,&t)!=EOF)
16 d[a][b1]=d[b1][a]=t;
17
18 for (int k=1;k<=n;k++)
19 for (int i=1;i<=n;i++)
20 for (int j=1;j<=n;j++)
21 if (d[i][k]<inf&&d[k][j]<inf)
22 d[i][j]=min(d[i][j],d[i][k]+d[k][j]);//fuluoyide弗洛伊德算法
23
24 int Min=inf,p,q;
25 for(int i=1;i<=n;i++)//zuihuaiqingkuang最坏情况处理
26 for(int j=1;j<=n;j++)
27 {
28 if(i==j)continue;
29 else
30 {
31 for(int k=1;k<=n;k++)
32 b[i][j]=max(b[i][j],min(d[i][k],d[j][k]));
33 }
34 if(Min>b[i][j])Min=b[i][j],p=i,q=j;
35 }
36 cout<<p<<" "<<q;
37 return 0;
38 }