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

为什么WA啊?

Posted by hmh0512 at 2009-07-27 16:29:49 on Problem 1029
#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
	int n,k,i,j,max,pos,pos2,flag,t,count;
	int b[1005],d[1005],a[105][1005],c[105];
	memset(b,0,sizeof(b));
	memset(d,0,sizeof(d));
	scanf("%d%d",&n,&k);	
	for(i=1;i<=k;i++)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=2*a[i][0];j++)
			scanf("%d%*c",&a[i][j]);
		scanf("%c",c+i);
		t=a[i][0];
		if(c[i]=='=')
			for(j=1;j<=2*t;j++)
				d[a[i][j]]=1;
		else if(c[i]=='<')
		{
			for(j=1;j<=t;j++)
				b[a[i][j]]--;
			for(j=1+t;j<=2*t;j++)
				b[a[i][j]]++;
		}
		else
		{
			for(j=1;j<=t;j++)
				b[a[i][j]]++;
			for(j=t+1;j<=2*t;j++)
				b[a[i][j]]--;
		}
	}
	count=0;
	for(i=1;i<=n;i++)
		if(d[i]!=1)
		{
			count++;
			pos=i;
		}
	if(count==1)
		printf("%d\n",pos);
	else
	{
		max=0;flag=1;
		for(i=1;i<=n;i++)
			if(d[i]!=1)
				if(abs(b[i])>max)
				{
					max=abs(b[i]);
					pos2=i;
				}
		for(i=pos2+1;i<=n;i++)
			if(d[i]!=1)
				if(abs(b[i])==max)
				{
					flag=0;
					break;
				}
		if(flag)
			printf("%d\n",pos2);
		else
			printf("0\n");
	}
}

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