#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
const int N=1010;
int par[N],dx[N],dy[N],repar[N],n;
void init(){for(int i=0;i<=n;i++)par[i]=i;}
int find(int x){return par[x]==x?par[x]:find(par[x]);}
void uni(int x,int y){par[find(x)]=find(y);}
double cald(int a,int b){
return (double)sqrt((dx[a]-dx[b])*(dx[a]-dx[b])+(dy[a]-dy[b])*(dy[a]-dy[b]));
}
int main(){
int d,p,q,len=0;
scanf("%d%d",&n,&d);
init();
for(int i=0;i<n;i++)scanf("%d%d",&dx[i],&dy[i]);
char c;
while(~scanf(" %c",&c)){
if(c=='O'){
scanf("%d",&p);
p--;
repar[len++]=p;
for(int i=0;i<len-1;i++){
if(repar[i]!=p&&cald(repar[i],p)<=(double)d)uni(repar[i],p);
}
}
else if(c=='S'){
scanf("%d%d",&p,&q);
p--,q--;
if(find(p)==find(q))puts("SUCCESS");
else puts("FAIL");
}
}
}
POJ2236
最新推荐文章于 2021-09-01 17:52:13 发布