| ||||||||||
| 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 | |||||||||
我的食物链哪里有问题?高手GG帮帮忙看看 xx//显示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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator