Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  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:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator