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错误呢?

Posted by heidaizx at 2008-08-12 10:05:40 on Problem 1330
#include<iostream>
using namespace std;
int c[10001];
int main()
{
	int n,i,j;
	cin>>n;
	while(n--)
	{
		for(i=1;i<=10001;i++)
		{
			c[i]=i;
		}
		int N;
		int a,b,d,e;
		cin>>N;
		N--;
		while(N--)
		{
			cin>>a>>b;
			c[b]=a;
		}
		cin>>d>>e;
		for(i=d;c[i]!=i;i=c[i])
		{
			int flag=0;
			for(j=e;c[j]!=j;j=c[j])
			{
				if(i==j)
				{
					flag=1;
					break;
				}
			}
			if(flag)break;
		}
		cout<<i<<endl;
	}
	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