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

为什么用个数组保存一条路线就会TL???????????????????????

Posted by yangyangyang91 at 2011-07-26 16:59:02 on Problem 1330
#include<stdio.h>
#include<string.h>
#define Max 10010
int f[Max];
void main()
{
    int a,b;
    int t;
    int n;
    int k;

    scanf("%d",&t);
    while(t--)
    {
        memset(f,0,sizeof(f));
        scanf("%d",&n);
        while(--n)
        {
            scanf("%d%d",&a,&b);
            f[b]=a;
        }

        scanf("%d%d",&a,&b);
        while(a)
        {
            k=b;
            while(k)
            {
                if(a==k)goto inx;
                k=f[k];
            }
            a=f[a];
        }
inx:
        printf("%d\n",a);
    }
}

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