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. 【C#设计模式1】单例模式

    一.引言 最近在设计模式的一些内容,主要的参考书籍是<Head First 设计模式>,同时在学习过程中也查看了很多博客园中关于设计模式的一些文章的,在这里记录下我的一些学习笔记,一是为了 ...

  2. git 创建标签推送远程分支

    目录 git 创建标签推送远程分支 查看tag 创建tag 推送标签到远程仓库 删除tag git 创建标签推送远程分支 标签概念: tag, 对于迭代频繁的项目. 每一个标签可以理解为一个版本. 创 ...

  3. VS2010开发.cpp与.c的注意事项

    VS2010开发.cpp与.c的注意事项 声明:引用请注明出处http://blog.csdn.net/lg1259156776/ 强大的VS2010,正是由于vs2010的完全封装,让现在的wind ...

  4. mysql每次update数据,自动更新对应表中时间字段

    mysql 已经创建完成表的情况下, 使得其中的时间字段 在每次 uodate 数据的时候 自动更新事件, 运行如下sql ALTER TABLE tab_name MODIFY COLUMN upd ...

  5. Linux "yin"才们的奇"yin"小技巧 --请用东北发音夸他们

    1. include/linux/bits.h GENMASK(h, l) /* * Create a contiguous bitmask starting at bit position @l a ...

  6. 经典排序算法及总结(python实现)

    目录 1.排序的基本概念和分类 排序的稳定性: 内排序和外排序 影响内排序算法性能的三个因素: 根据排序过程中借助的主要操作,可把内排序分为: 按照算法复杂度可分为两类: 2.冒泡排序 BubbleS ...

  7. Java中 final和static解析

    一.final 根据程序上下文环境,Java关键字final有"这是无法改变的"或者"终态的"含义,它可以修饰非抽象类.非抽象类成员方法和变量.你可能出于两种理 ...

  8. 让Sublime Text3支持新建.vue高亮显示模板

    首先要使用Package Control,安装要好 Vue Syntax Highlight和sublimetmpl插件. 1, 在Packages\SublimeTmpl\templates目录下新 ...

  9. JS 04 Date_Math_String_Object

    Date <script> //1.Date对象 var d1 = new Date(); //Thu May 02 2019 14:27:19 GMT+0800 (中国标准时间) con ...

  10. APK反编译教程

    在学习Android开发的过程你,你往往会去借鉴别人的应用是怎么开发的,那些漂亮的动画和精致的布局可能会让你爱不释手,作为一个开发者,你可能会很想知道这些效果界面是怎么去实现的,这时,你便可以对改应用 ...