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:Notice~老做水题~作孽啊~贡献脑残代码~

Posted by like680623 at 2011-02-02 11:09:19 on Problem 1330
#include<iostream>
#include<fstream>
using namespace std;
int value[10020];
int main()
{
	//ifstream cin("a.txt");
	int tot, n, a, b, c, d;
	cin>>tot;
	while (tot--)
	{
		memset(value, 0, sizeof(value));
		cin>>n;
		for (int i = 1; i <= n - 1; i++)
		{
			cin>>a>>b;
			value[b] = a;
		}
		cin>>c>>d;
		while (c)
		{
			int t = 1, k = d;
			while (k)
			{
				if (c == k)
				{
					printf("%d\n", c);
					t = 0;break;
				}
				k = value[k];
			}
			if (!t)break;
			c = value[c];
		}
	}
	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