Wireless Network(并查集)
#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(并查集)的更多相关文章
- POJ 2236 Wireless Network (并查集)
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 18066 Accepted: 761 ...
- POJ2236 Wireless Network 并查集简单应用
Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have ...
- Wireless Network 并查集
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wi ...
- poj 2236 Wireless Network (并查集)
链接:http://poj.org/problem?id=2236 题意: 有一个计算机网络,n台计算机全部坏了,给你两种操作: 1.O x 修复第x台计算机 2.S x,y 判断两台计算机是否联通 ...
- POJ 2236 Wireless Network [并查集+几何坐标 ]
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wi ...
- POJ2236 Wireless Network 并查集
水题 #include<cstdio> #include<cstring> #include<queue> #include<set> #include ...
- [LA] 3027 - Corporative Network [并查集]
A very big corporation is developing its corporative network. In the beginning each of the N enterpr ...
- LA 3027 Corporative Network 并查集记录点到根的距离
Corporative Network Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [S ...
- UVALive - 3027 Corporative Network (并查集)
这题比较简单,注意路径压缩即可. AC代码 //#define LOCAL #include <stdio.h> #include <algorithm> using name ...
- 【转】并查集&MST题集
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基 ...
随机推荐
- Docker Swarm 集群(十七)
目录 一.Docker Swarm 概念 1.集群 2.Docker Swarm 3.重要概念 swarm node service 二.创建 Swarm 集群 1.环境准备 2.创建 swarm 3 ...
- Xena L23网络测试仪Valkyrie使用技巧100例:使用Xena官方在线演示设备 (编号00)
需求# 1.新用户:没有硬件,想看看软件长什么样,好不好用,风格如何,怎么办? 2.代理商:没有硬件,想给客户Show一下Xena高大上的软件,怎么办? 3.老用户:邮件推送了新的软件版本,据说很多新 ...
- 安装LoadRunner各种提示解决方法(转载)
原文地址链接:https://jingyan.baidu.com/article/915fc414fc60fc51394b20fa.html 1.问:当安装提示"Micosoft Visua ...
- tab页签
<div class="fl" id="newsBox"> <div class="tab1 grayBar"> & ...
- NET Core 3.0中的WPF
在.NET Core 3.0中的WPF中使用IOC图文教程 我们都知道.NET Core 3.0已经发布了第六个预览版,我们也知道.NET Core 3.0现在已经支持创建WPF项目了,刚好今天在 ...
- jquery的ajax设置为同步
在使用$.get或者$.post的时候,前面加上 $.ajaxSettings.async = false; 使用完之后再设置为异步 $.ajaxSettings.async = true; 而在使用 ...
- react native 中 Demensions的坑
简单描述下碰到的问题:Demensions.get('window').height,一般拿来获取屏幕高度的.但是在小米mix3上面(其他安卓机型可能也会有)无论底部的虚拟物理键盘显示与否(底部的返回 ...
- 2019php面试大全
一 .PHP基础部分 1.PHP语言的一大优势是跨平台,什么是跨平台? PHP的运行环境最优搭配为Apache+MySQL+PHP,此运行环境可以在不同操作系统(例如windows.Linux等)上配 ...
- spring cloud微服务实践二
在上一篇,我们已经搭建了spring cloud微服务中的注册中心.但只有一个注册中心还远远不够. 接下来我们就来尝试提供服务. 注:这一个系列的开发环境版本为 java1.8, spring boo ...
- SAS学习笔记9 利用SAS绘制地图
绘制世界地图 proc gmap过程: map=指定绘图的map数据集 data=指定地图的对应数据集 id指定map数据集和对应数据集中都有的变量,一般为各区域的代码,作为两个数据集的连接变量 分色 ...