| ||||||||||
| 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 | |||||||||
TLE///////有谁帮我看看#include <stdio.h>
void main()
{
int p,x,y,b[30001],u[30001];
bool sign;
scanf("%d",&p);
for(int i=1;i<=30000;i++)
u[i]=b[i]=0;
char oper;
while(p--)
{
scanf("%c",&oper);
scanf("%c",&oper);
if(oper=='M')
{
sign=1;
scanf("%d%d",&x,&y);
int t=x,f=y;
while(sign&&b[x])
{
if(x==y)
sign=0;
x=b[x];
}
if(x==y)
sign=0;
while(sign&&u[y])
{
if(t==y)
sign=0;
y=u[y];
}
if(t==y)
sign=0;
if(sign)
{
b[x]=y;
u[y]=x;
}
}
else
{
int count=0;
scanf("%d",&x);
while(b[x])
{
count++;
x=b[x];
}
printf("%d\n",count);
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator