测试结果1: 通过本测试点|有效耗时94ms
测试结果2: 通过本测试点|有效耗时140ms
测试结果3: 通过本测试点|有效耗时157ms
测试结果4: 通过本测试点|有效耗时156ms
测试结果5: 通过本测试点|有效耗时140ms
测试结果6: 通过本测试点|有效耗时157ms
测试结果7: 通过本测试点|有效耗时140ms
测试结果8: 通过本测试点|有效耗时141ms
测试结果9: 通过本测试点|有效耗时156ms
测试结果10: 通过本测试点|有效耗时141ms
提交代码: view sourceprint?
#include<stdio.h>
int a[1000001],dog1,dog2,N;
bool d[1000001];
int main()
{
int m,n,i,j;
scanf("%d",&N);
for(i=1;i<N;i++)
{
scanf("%d%d",&m,&j);
a[j]=m;
}
scanf("%d%d",&dog1,&dog2);
while(dog1)d[dog1]=true,dog1=a[dog1];
while(dog2&&!d[dog2])dog2=a[dog2];
printf("%d",dog2);
return 0;
}
。。。。。。。。。。。。。。。。。。。
通过本测试点|有效耗时437ms
测试结果2: 通过本测试点|有效耗时1016ms
测试结果3: 选手程序运行超过时限
测试结果4: 通过本测试点|有效耗时1015ms
测试结果5: 通过本测试点|有效耗时1016ms
测试结果6: 选手程序运行超过时限
测试结果7: 测试结果错误.错误结果为:1
正确结果应为:12
测试结果8: 通过本测试点|有效耗时1016ms
测试结果9: 选手程序运行超过时限
测试结果10: 选手程序运行超过时限
#include<iostream.h>
int a[1000001],dog1,dog2,N;
bool d[1000001];
int main()
{
int m,n,i,j;
cin>>N;
for(i=1;i<N;i++)
{
cin>>m>>j;
a[j]=m;
}
cin>>dog1>>dog2;
while(dog1)d[dog1]=true,dog1=a[dog1];
while(dog2&&!d[dog2])dog2=a[dog2];
cout<<dog2;
return 0;
}