Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水过~#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: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator