Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 求哪位大牛看看那里错了WA

Posted by louchiheng at 2016-03-31 13:18:13 on Problem 2236
```#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
struct xy
{
long long x,y;
}a[1002];
long long f[1002],x,y,i,n,j;
double d;
char ch[1];
bool b[1002];
int getfather(int x)
{
if(f[x]==x)return x;
f[x]=getfather(f[x]);
return f[x];
}
void hb(int x,int y)
{
f[getfather(y)]=getfather(x);
}
double dis()
{
return sqrt(1.0*(a[i].x-a[j].x)*(a[i].x-a[j].x)+1.0*(a[i].y-a[j].y)*(a[i].y-a[j].y));
}
bool judge(int x,int y)
{
if(getfather(x)==getfather(y))return 1;
return 0;
}
int main()
{
scanf("%d%lf",&n,&d);
memset(b,0,sizeof(b));
for(i=1;i<=n;++i)
{
scanf("%d%d",&a[i].x,&a[i].y);
f[i]=i;
}
while(scanf("%s",ch)!=EOF)
{
if(ch[0]=='O')
{
scanf("%d",&i);
for(j=1;j<=n;++j)if(b[j]&&i!=j&&dis()<=d)
if(x<y)hb(x,y);else hb(y,x);
b[i]=1;
}
if(ch[0]=='S')
{
scanf("%d%d",&x,&y);
if(judge(x,y))printf("SUCCESS\n");else printf("FAIL\n");
}
}
}```

Followed by: