#include <bits/stdc++.h>
using namespace std;
const int inf=2e9;
int a[105][105],a1[105][105],n,m,ans=inf;
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(i!=j)
a1[i][j]=1e9;
for(int i=1;i<=m;i++)
{
int s,e,time;
cin>>s>>e>>time;
if(s==e)
continue;
if(a[s][e]==0)
a[s][e]=time;
a[s][e]=min(a[s][e],time);
a[e][s]=a[s][e];
a1[s][e]=a[s][e];
a1[e][s]=a[s][e];
}
for(int k=1;k<=n;k++)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i!=j && a[i][k]>0 && a[k][j]>0)
ans=min(ans,a1[i][j]+a[i][k]+a[k][j]);
if(a1[i][k]+a1[k][j]<a1[i][j])
a1[i][j]=a1[i][k]+a1[k][j];
}
}
}
if(ans!=inf)
cout<<ans;
else
cout<<"No solution.";
return 0;
}
为什么第二个点会WA