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

我的食物链哪里有问题?高手GG帮帮忙看看 xx

Posted by herogxo at 2006-12-06 12:03:15 on Problem 1182
//显示wrong answer 不知道哪里有问题 我自己输出的结果是对的 自己举了几个例子也符合 

#include <stdio.h>
#define N 50000
#define K 100000

int main()
{
	int n,k,d,x,y,a[N+1],num=0,i;
	scanf("%d %d",&n,&k);
	for(i=0;i<=n;i++)
		a[i]=0;
	for(i=0;i<k;i++)
	{
		scanf("%d %d %d",&d,&x,&y);
		if(x>n||y>n)
		{
			num++;
			continue;
		}
		if(d==2&&x==y)
		{
			num++;
			continue;
		}
		if(a[x]==0&&a[y]==0)
		{
			if(d==1)
				a[x]=a[y]=1;
			else
			{
				a[x]=1;
				a[y]=2;
			}
		}
		else if(a[x]!=0&&a[y]!=0)
		{
			if(d==2&&(a[x]==1&&a[y]==3||a[x]==2&&a[y]==1||a[x]==3&&a[y]==2||a[x]==a[y]))
				num++;
			else if(d==1&&a[x]!=a[y])
				num++;
		}
		else if(a[x]==0)
		{
			if(d==1)
				a[x]=a[y];
			else
				a[x]=(a[y]+1)%3+1;
		}
		else if(a[y]==0)
		{
			if(d==1)
				a[y]=a[x];
			else
				a[y]=a[x]%3+1;
		}
	}
	printf("%d\n",num);
	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