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 jean890915 at 2011-10-06 16:07:15 on Problem 3505
In Reply To:结果都对,就是WA,哪位高手帮看一下啊! Posted by:renjieye at 2008-05-02 14:06:08
> #include<stdio.h>
> #define N 50
> void rank(int a[],int x)
> {
> 	int i,j,t;
> 	for(j=0;j<x-1;j++)
> 		for(i=0;i<x-j-1;i++)
> 			if(a[i]>a[i+1])
> 			{t=a[i];a[i]=a[i+1];a[i+1]=t;}
> }
> int tiny(int a,int b)
> {
> 	if(a<b)
> 		return a;
> 	else
> 		return b;
> }
> int line(int c)
> {
> 	if(c<0)
> 		return -c;
> 	else
> 		return c;
> }
> 
> main()
> {
> 	int b[N][N],d,f=1,m,n,i,j,x,x1,y,z,sum1,sum2;
> 	int sum[N],s[N],a1[N],l[N],h[N];
> 	int a[N][2],p[N][N],c[N][N],e[N][N];
> 	scanf("%d",&n);
> 	if(n<=100&&n>0)
> 	{
> 		for(m=0;m<n;m++)
> 		{
> 			for(j=0;j<2;j++)
> 				scanf("%d",&a[m][j]);
> 			h[m]=a[m][0];
> 			l[m]=a[m][1];
> 			if(h[m]<=50&&h[m]>0)
> 				if(l[m]<=50&&l[m]>1)
> 				{
> 					for(i=0;i<h[m];i++)
> 					{
> 						b[m][i]=0;
> 						for(j=0;j<l[m];j++)
> 						{
> 							scanf("%d",&p[i][j]);
> 							b[m][i]+=p[i][j];
> 						}
> 					}
> 					sum[m]=0;
> 					for(i=0;i<h[m];i++)
> 					{
> 						if(p[i][0]==-1)
> 						{
> 							e[m][i]=1;
> 							x=0;
> 							for(j=0;j<l[m];j++)
> 							{
> 								if(p[i][j]!=-1)
> 								{
> 									a1[x]=p[i][j];
> 									x++;
> 								}
> 							}
> 							rank(a1,x);
> 							x1=0;
> 							y=0;
> 							for(x1=0;x1<x;x1++)
> 							{
> 								for(j=0;j<l[m];j++)
> 								{
> 									if(a1[x1]==p[i][j])
> 									{
> 										c[i][y]=j;
> 										y++;
> 										break;
> 									}
> 								}
> 							}
> 							sum1=tiny(line(c[i][0]),l[m]-line(c[i][0]))*5;
> 							for(z=1;z<y;z++)
> 							{
> 								sum1+=tiny(line(c[i][z]-c[i][z-1]),l[m]-line(c[i][z]-c[i][z-1]))*5;
> 							}
> 							sum2=20*x*i;
> 							s[i]=sum1+sum2;
> 							sum[m]+=s[i];
> 						}
> 						else
> 							e[m][i]=0;
> 					}              //for(i)    				
> 				}                //if(h,l)
> 		}                 //for(m)
> 		for(m=0;m<n;m++)
> 		{
> 			for(i=0;i<h[m];i++)
> 			{
> 				f*=e[m][i];
> 				if(b[m][i]>=(-1)*i+2)
> 					d=1;
> 				else
> 				{
> 					d=0;
> 					break;
> 				}
> 			}
> 		}
> 		switch(d*f)
> 		case(1):for(m=0;m<n;m++)
> 				printf("%d\n",sum[m]);
> 	}
> 	return 0;
> }
> 

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