拿以前的代码过来秒掉了,这代码可以作为一块好的模板了.......
/*
ID:sevenst4
LANG:C++
PROG:agrinet
*/
#include<stdio.h>
using namespace std;int main()
{freopen( "agrinet.in","r",stdin );freopen( "agrinet.out","w",stdout );int i,j,k,n,a[101][101];while( scanf( "%d",&n )!=EOF ){for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )scanf( "%d",&a[i][j] );}int flag[101]={0};int sum=0;flag[1]=1;for( k=1;k<n;k++ ){int min=-1,min_i;for( i=1;i<=n;i++ ){if( flag[i]==0 && ( min==-1||a[1][i]<min ) ){min=a[1][i];min_i=i;}}flag[min_i]=1;for( i=1;i<=n;i++ ){if( flag[i]==0 && a[1][i]>a[min_i][i] )a[1][i]=a[min_i][i];}sum+=a[1][min_i];}printf( "%d\n",sum );}return 0;
}