POJ - 2236

 #include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std; int n,d;
char c;
int p,q;
int book[]={},f[]; //分别是 标记是否修好 , 找爸 struct note
{
int x,y;
}a[]; //记录坐标 int getf(int u)
{
return u==f[u]? u:getf(f[u]);
} void merge(int x,int y)
{
x=getf(x);
y=getf(y);
if(x!=y)
{
f[y]=x;
}
} int main()
{
cin>>n>>d;
for(int i=;i<=n;i++)
{
f[i]=i;
cin>>a[i].x>>a[i].y;
}
while(cin>>c)
{
if(c=='O') //修
{
cin>>p;
book[p]=; //修好了 ,下面进行寻找
for(int i=;i<=n;i++)
{
//第i个电脑不和第p的电脑超出距离,并且第i个电脑已经被修好 是能连通的基本条件
if( d*d >= 1.0*((a[p].x-a[i].x)*(a[p].x-a[i].x)+(a[p].y-a[i].y)*(a[p].y-a[i].y)) && book[i]==)
merge(f[p],f[i]); //这里左右位置不要变,要一直都把电脑p作为爸爸
}
}
else if(c=='S')
{
cin>>p>>q;
if(getf(p)==getf(q))
cout<<"SUCCESS"<<endl;
else
cout<<"FAIL"<<endl;
}
}
}

Wireless Network(并查集)的更多相关文章

  1. POJ 2236 Wireless Network (并查集)

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

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

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

  3. Wireless Network 并查集

    An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wi ...

  4. poj 2236 Wireless Network (并查集)

    链接:http://poj.org/problem?id=2236 题意: 有一个计算机网络,n台计算机全部坏了,给你两种操作: 1.O x 修复第x台计算机 2.S x,y 判断两台计算机是否联通 ...

  5. POJ 2236 Wireless Network [并查集+几何坐标 ]

    An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wi ...

  6. POJ2236 Wireless Network 并查集

    水题 #include<cstdio> #include<cstring> #include<queue> #include<set> #include ...

  7. [LA] 3027 - Corporative Network [并查集]

    A very big corporation is developing its corporative network. In the beginning each of the N enterpr ...

  8. LA 3027 Corporative Network 并查集记录点到根的距离

    Corporative Network Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu [S ...

  9. UVALive - 3027 Corporative Network (并查集)

    这题比较简单,注意路径压缩即可. AC代码 //#define LOCAL #include <stdio.h> #include <algorithm> using name ...

  10. 【转】并查集&MST题集

    转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基 ...

随机推荐

  1. python介绍,计算机组成。内存分布,进制,操作系统介绍

    学习小方法 ​三个W一个Hwwwh:what(是什么) why(为什么) where(怎么用) how(如何用) 来思考知识点多练,多写,多敲代码增加熟练度与代码量​ Python 是一门面向后台的编 ...

  2. 【数据库开发】在Windows上以服务方式运行 MSOPenTech/Redis

    在Windows上以服务方式运行 MSOPenTech/Redis ServiceStack.Redis 使用教程里提到Redis最好还是部署到Linux下去,Windows只是用来做开发环境,现在这 ...

  3. 【计算机视觉】BING: Binarized Normed Gradients for Objectness Estimation at 300fps

    BING: Binarized Normed Gradients for Objectness Estimation at 300fps Ming-Ming Cheng, Ziming Zhang, ...

  4. ELK优化难题解决

    你头疼的ELK难题,本文几乎都解决了 一.ELK实用知识点总结 1.编码转换问题 这个问题,主要就是中文乱码. input中的codec=>plain转码: codec => plain ...

  5. js修改css属性值

    推荐用dom.style.setProperty('属性','属性值'); 例如: $("#id")[0].style.setProperty('margin-top','1px' ...

  6. Servlet技术之——概述、实现、细节、获取资源、ServletConfig、ServletContext

    Servlet概述.实现.细节.获取资源.ServletConfig.ServletContext (一) Setvlet基本概述 (1) 什么是Servlet ? Servlet(Server Ap ...

  7. java用POI导出Excel

    架构SSM + Maven 一.添加依赖: <dependency> <groupId>org.apache.poi</groupId> <artifactI ...

  8. 有关Linux服务器的一些配置

    1.Redis部署 1.版本 redis-3.0.72.上传解压 3.编译 make && make install 问题:/bin/sh: cc: command not found ...

  9. linux下查看当前进程以及杀死进程

    ###linux下查看当前进程以及杀死进程 查看进程 ps命令查找与进程相关的PID号: ps a :显示现行终端机下的所有程序,包括其他用户的程序. ps -A :显示所有程序. ps c :列出程 ...

  10. MyBatis_02 框架

    今日内容 动态SQL语句 Xml方式 注解方式 MyBatis的缓存 MyBatis的关联查询 MyBatis逆向工程 动态SQL语句 动态SQL是什么 就是相对与固定SQL.就是通过传入的参数不一样 ...