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 |
为什么会是WA啊!!!求助大牛!!万分感激~#include<stdio.h> #include<string.h> int a[102][102]; int b[102][102]; int p[1000]; void main() { int i,j,k,l,min,n,c,d,t,flag;__int64 sum; while(scanf("%d",&n)!=EOF && n) { sum=0; for(i=1;i<=n;i++) for(j=1;j<=n;j++) { scanf("%d",&a[i][j]); } k=1; memset(p,0,sizeof(p)); for(i=1;i<=102;i++) for(j=1;j<=102;j++) { b[i][j]=0; } for(l=1;l<n;l++) { min=100001; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { if(min>a[i][j] && b[i][j]==0) { flag=0; p[i]++;p[j]++; for(t=1;t<=n;t++) { if(p[t]==0) continue; if(p[t]!=2) { flag=1;break; } } if(flag==1) { min=a[i][j]; c=i;d=j; } p[i]--;p[j]--; } } } p[c]++;p[d]++; b[c][d]=1; sum=sum+min; } printf("%I64d\n",sum); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator