作者:
navystar
,
2023-05-26 16:37:34
,
所有人可见
,
阅读 5
//这里填你的代码^^
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1e6 + 10;
struct node
{
int x, y;
}edg[N];
int p[N];
bool st[N];
inline int find(int x)
{
return p[x] == x ? x : find(p[x]);
}
inline double get(int xx, int yy)
{
double dx = edg[xx].x - edg[yy].x, dy = edg[xx].y - edg[yy].y;
return sqrt(dx *dx + dy * dy);
}
inline void solve()
{
int n, d;
cin >> n >> d;
for (int i = 1; i <= n; i ++ ) cin >> edg[i].x >> edg[i].y;
for (int i = 1; i <= n; i ++ ) p[i] = i;
char ch;
while (cin >> ch)
{
if (ch == 'O')
{
int x;
cin >> x;
st[x] = true;
for (int i = 1; i <= n; i ++ )
if (st[i] && get(x, i) <= d)
p[find(x)] = find(i);
}
else
{
int x, y;
cin >> x >> y;
if (find(x) == find(y)) cout << "SUCCESS" << endl;
else cout << "FAIL"<< endl;
}
}
}
int main()
{
cin.tie(nullptr) -> sync_with_stdio(0);
solve();
return 0;
}
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~