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:为什么会是WA啊!!!求助大牛!!万分感激~

Posted by 25_402 at 2009-05-09 00:07:11 on Problem 1258
In Reply To:为什么会是WA啊!!!求助大牛!!万分感激~ Posted by:25_402 at 2009-05-09 00:03:47
> #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:
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