| ||||||||||
| 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 | |||||||||
为什么用个数组保存一条路线就会TL???????????????????????#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator