Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:一直WA,不明白为什么，谁能给个测试数据呀

Posted by gezhongkongenenen at 2013-08-03 11:20:22 on Problem 3321
In Reply To:一直WA,不明白为什么，谁能给个测试数据呀 Posted by:mountainhigh at 2011-05-05 22:26:44
```> #include<iostream>
> #include<cstring>
> using namespace std;
> int N,M;
> struct fork
> {
> 	int parent,num,flag;
> }c[100100];
> int main()
> {
> 	int i,j,x,y,lj;
> 	char q;
> 	cin>>N;
> 	for(i=1;i<=N;i++)
> 	{
> 		c[i].parent=0;
> 		c[i].num=1;
> 		c[i].flag=1;
> 	}
> 	for(i=0;i<N-1;i++)
> 	{
> 		cin>>x>>y;
> 		if(x>y)
> 		{
> 			int chang;
> 			chang=x;x=y;y=chang;
> 		}
> 		c[y].parent=x;
> 		lj=x;
> 		while(c[lj].parent)
> 		{
> 		    c[lj].num+=c[y].num;
> 			lj=c[lj].parent;
> 		}
> 		c[1].num+=c[y].num;
> 	}
> 	cin>>M;
> 	for(i=0;i<M;i++)
> 	{
> 		cin>>q;
> 		cin>>j;
> 		if(q=='Q')
> 			cout<<c[j].num<<endl;
> 		else
> 		{
> 			if(c[j].flag==1)
> 			{
> 				c[j].flag=0;
> 				lj=j;
> 				while(c[lj].parent)
> 				{
> 					c[lj].num--;
> 					lj=c[lj].parent;
> 				}
> 				c[1].num--;
> 			}
> 			else
> 		    {
> 				c[j].flag=1;
> 				lj=j;
> 				while(c[lj].parent)
> 				{
> 					c[lj].num++;
> 					lj=c[lj].parent;
> 				}
> 			    c[1].num++;
> 		    }
> 		}
> 	}
> 	return 0;
> }
>
>
>
>
> 感觉是建边是方向搞错了
```

Followed by: