Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:贴码

Posted by zjf1649311651 at 2016-10-03 14:49:20 on Problem 1125
In Reply To:贴码 Posted by:zjf1649311651 at 2016-10-03 14:39:27
```> #include<iostream>
> #include<string.h>
> #include<algorithm>
> using namespace std;
> const int maxn=100,maxm=1000000;
> int A[maxn][maxn];
> int main()
> {
>     int n,m,a,b;
>     while (cin>>n &&  n)
>     {
>        for (int i=0;i<n;i++)
>          for (int j=0;j<n;j++)
>            A[i][j]=maxm;
>        for (int i=0;i<n;i++)
>        {
>            scanf("%d",&m);
>            for (int j=0;j<m;j++)
>            {
>                scanf("%d%d",&a,&b);
>                A[i][a-1]=b;
>            }
>        }
>        for (int k=0;k<n;k++)
>          for (int i=0;i<n;i++)
>            for (int j=0;j<n;j++)
>              if (i!=j) A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
>        int k,ans=maxm;
>        for (int i=0;i<n;i++)
>        {
>            int max=0;
>            for (int j=0;j<n;j++)
>              if (i!=j && A[i][j]>max)
>                max=A[i][j];
>            if (max<ans)
>            {
>              ans=max;
>              k=i;
>            }
>        }
>        cout<<k+1<<" "<<ans<<endl;
>     }
>     return 0;
> }
```

Followed by: