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
ACM ICPC 2018 World Finals

## 水过一百题，虽然很多都是水题，但是还是很开心，贴出代码（大牛轻喷）

Posted by 894212550 at 2014-11-18 21:49:07 on Problem 2236 and last updated at 2014-11-18 21:49:45
```#include <stdio.h>

#define MAXN 1010

struct POINT
{
int x,y;
};

int n,count,d;
struct POINT node[MAXN];
int father[MAXN],repaired[MAXN];

int dis(int x,int y)
{
int tempx=node[x].x-node[y].x,tempy=node[x].y-node[y].y;
if ((tempx*tempx+tempy*tempy)<=d*d)
{
return 1;
}
else return 0;
}

int find_set(int x)
{
if(x!=father[x])
father[x]=find_set(father[x]);
return father[x];
}

void init()
{
int i;
for(i=1;i<=n;i++)
father[i]=i;
}

void union_set(int x,int y)
{
x=find_set(x);
y=find_set(y);
father[y]=father[x];
}

int main()
{
int i,x,y;
char cmd;
count=0;
scanf("%d %d",&n,&d);
init();
for (i=1;i<=n;i++)
{
scanf("%d %d",&node[i].x,&node[i].y);
}
while (scanf(" %c",&cmd)!=EOF)
{
if (cmd=='O')
{
scanf("%d",&x);
for (i=0;i<count;i++)
{
if(dis(repaired[i],x))
union_set(repaired[i],x);
}
repaired[count++]=x;
}
else{
scanf("%d %d",&x,&y);
if (find_set(x)==find_set(y))
{
printf("SUCCESS\n");
}
else printf("FAIL\n");
}
}
return 0;
}
```

Followed by: