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

## 水过~

Posted by 1654995440 at 2015-02-07 16:56:45 on Problem 2139
```#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,cow[305][305],mo[305];
const int MAX=100000;
int main()
{
cin>>n>>m;
for(int i=0;i<=n;i++)
{
fill(cow[i],cow[i]+n+1,MAX);
cow[i][i]=0;
}

while(m--)
{
int num;
scanf("%d",&num);
for(int i=0;i<num;i++)
scanf("%d",&mo[i]);
for(int i=0;i<num;i++)
for(int j=i+1;j<num;j++)
{
cow[mo[i]-1][mo[j]-1]=1;
cow[mo[j]-1][mo[i]-1]=1;
}

}
for(int k=0;k<n;k++)
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cow[i][j]=min(cow[i][j],cow[i][k]+cow[k][j]);
int msum=1000000;
for(int i=0;i<n;i++)
{
int sum=0;
for(int j=0;j<n;j++)
sum+=cow[i][j];
if(sum<msum)
msum=sum;
}
printf("%d\n",msum*100/(n-1));

return 0;
}
```

Followed by: