#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int par[];
bool b[];//判断哪个电脑被修好了
struct
{
int x,y;
}a[];
void init(int n)
{
for(int i=;i<=n;i++)
{
par[i]=i;
}
}
int find(int x)
{
if(par[x]==x)
{
return x;
}
else
{
return par[x]=find(par[x]);
}
}
void unite(int x,int y)
{
x=find(x);
y=find(y);
if(x!=y)
par[x]=y;
else
return ;
}
bool same(int x,int y)
{
return find(x)==find(y);
}
int main (void)
{
memset(b,false,sizeof(b));
int num;int maxx;
cin>>num>>maxx;
init(num);
for(int i=;i<=num;i++)
{
scanf("%d %d",&a[i].x,&a[i].y);
}
char op;
int id;
while(~scanf(" %c",&op))
{
if(op=='O')
{
scanf("%d",&id);
b[id]=true; for(int i=;i<=num;i++)
{
if(b[i]==true)
{
int di=(a[id].x-a[i].x)*(a[id].x-a[i].x)+
(a[id].y-a[i].y)*(a[id].y-a[i].y);
if(di<=maxx*maxx)//如果比限制距离小,可以合并
{
unite(id,i);
}
}
}
}
if(op=='S')
{
int c,d;
scanf("%d %d",&c,&d);
if(find(d)==find(c))
printf("SUCCESS\n");
else
printf("FAIL\n");
}
}
return ;
}

A - Wireless Network的更多相关文章

  1. [并查集] POJ 2236 Wireless Network

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 25022   Accepted: 103 ...

  2. POJ 2236 Wireless Network(并查集)

    传送门  Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 24513   Accepted ...

  3. poj 2236:Wireless Network(并查集,提高题)

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 16065   Accepted: 677 ...

  4. Top 10 Free Wireless Network hacking/monitoring tools for ethical hackers and businesses

    There are lots of free tools available online to get easy access to the WiFi networks intended to he ...

  5. Wireless Network

    Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 19626 Accepted: 8234 De ...

  6. POJ 2236 Wireless Network (并查集)

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 18066   Accepted: 761 ...

  7. POJ 2236 Wireless Network (并查集)

    Wireless Network 题目链接: http://acm.hust.edu.cn/vjudge/contest/123393#problem/A Description An earthqu ...

  8. Wireless Network(POJ 2236)

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 20724   Accepted: 871 ...

  9. POJ - 2336 Wireless Network

    Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have ...

  10. POJ2236 Wireless Network 并查集简单应用

    Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have ...

随机推荐

  1. Delphi类的默认区域

    //类中数据成员的排列顺序一般是: 字段.方法.属性 //访问权限区域的顺序一般是:   无限制区(默认 published)   private   protected   public   pub ...

  2. ABAP 动态where 使用

    REPORT ztest001_xch. TABLES: makt. DATA where_tab() OCCURS WITH HEADER LINE. DATA : wa_itab LIKE mak ...

  3. ubuntu搭建nginx

    1.下载nginx压缩包 2.上传.解压 tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 3.安装 make  install 4.启动,停止 ,重启 服务 可 ...

  4. Label标签 自动触发onclick,点击内部的Input

    最近项目遇到了一个bug,点击外层元素会直接触发元素内部的input框.(外层元素用的是label包裹的).找了很久才发现是label标签造成的. label定义和用法: label 标签为 inpu ...

  5. leetcode 792. Number of Matching Subsequences

    Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of ...

  6. c++变量定义

    float **a 表示a是一个“指针的指针”,也可以理解为是一个二维数组的指针,***a具有类似的解释,可以理解为是一个三维数组的指针.

  7. JSR 303 - Bean Validation 是什么?

    关于 Bean Validation JSR 303 - Bean Validation 是jree6 中的一项子规范,JSR 303 - Bean Validation着重解决以下实际问题: 在任何 ...

  8. 上传图片 ajax input type="file" 兼容 ie chroem 火狐

    上传图片,转载请注明出处!!! 兼容 ie chroem 火狐 html: <div id="uploadForm"> <input id="file& ...

  9. 并不对劲的CTS2019

    day0 没有C day1 t1:并不想简述题意 10分暴力走人 t2:有\(n\)个在\([1,D]\)内的均匀随机整数,问有多少的概率出现\(m\)对相同的 设\(f(i,j)\)表示考虑前\(i ...

  10. nginx开发_ngx_palloc源码解析

    功能简介 ngx_pool_t是nginx开发中最经常使用到的内存容器.对动态内存的封装,由框架进行创建与释放,模块开发过程中仅需要进行内存申请,不需要关注何时释放.常见的pool对象有: 1. ng ...