#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. mongodb学习之:mongo安装以及远程访问

    在linux下通过apt-get install mongo的方式一键式安装mongo 安装后mongo的配置文件位于/etc/mongodb.conf. 里面有mongo的各项配置,文件内容如下:重 ...

  2. HTML5 Canvas 画图入门

    HTML5 Canvas 画图入门 HTML5 Canvas 画图入门,仅供学习參考 <!DOCTYPE html> <html> <head> <meta ...

  3. 建立FTP服务器(FTP服务器名要与创建的用户名一致)

    1新建用户 2. 3.建立FTP

  4. Java其实不支持垃圾回收

    Java其实不支持垃圾回收.如果真的支持的话,大多数Java程序在运行的一开始就应该把程序本身删除,因为这些程序本身就是垃圾.   // TODO: This is a 分割线. Please no ...

  5. jquery DataTables表格插件的使用(网页数据表格化及分页显示)

    DataTables - 非常强大的 jQuery 表格插件,可变宽页码浏览,现场过滤. 多列排序,自动探测数据类型,智能列宽,可从几乎任何数据源获取数据. 那么在Bootstrap下如何使用Data ...

  6. 在springboot中使用Mybatis Generator的两种方式

    介绍 Mybatis Generator(MBG)是Mybatis的一个代码生成工具.MBG解决了对数据库操作有最大影响的一些CRUD操作,很大程度上提升开发效率.如果需要联合查询仍然需要手写sql. ...

  7. 详细阐述ping命令中请求超时与无法访问的区别

    1.Request timed out 这是大家经常碰到的提示信息,很多文章中说这是对方机器置了过滤ICMP数据包,从上面工作过程来看,这是不完全 正确的,至少有下几种情况. (1) 对方已关机,或者 ...

  8. source insight 快捷键

    source insight 返回上一视图 快捷键:ALT+, 浏览项目符号:F7 全局浏览查找某个名称开头的函数或结构体等

  9. ansible管理windows实践

    一.前言 近期打算搞搞自动部署,因为是windows服务器,一些工具和系统支持都不是太好.最后发现ansible比较火,最重要的是他支持windows.本文主要就ansible 在windows使用环 ...

  10. Android Studio中的“favorites”和“bookmark”

    做项目难免来回查看某个文件的某个方法,某些文件可能访问率很高, 为了加快开发效率楼主推荐使用favorites (文件)bookmark (代码 行). favorites 的添加就在文件单击右键ad ...