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 小希的迷宫 基 ...
随机推荐
- pip3快速下载paddle
安装百度的paddle paddle时很慢,后来采用国内的源,速度嗖嗖滴 pip3 install -U paddlepaddle -i https://pypi.douban.com/simple/ ...
- Ctrl + 逗号快捷键被占用[搜狗输入法]
Ctrl+,(或者Ctrl+逗号)被占用. 快捷键忽然不能用了,只要一用快捷键自动唤醒搜狗输入法,呵呵.极度影响使用. 就说怎么禁掉吧: 其他快捷键禁用参考 参考: 搜狗桌面论坛 注:搜狗输入法一次占 ...
- Asp.Net文件的上传和下载
aspx页面: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="上传和下载文件. ...
- Python 面向对象总结
面向对象 类 class 类型 类变量 实例方法 init attack bite 类指针 - 指向父类 对象 对象指针 实例变量 self.name slef.age 组合 一个对象作为一个属性 s ...
- springboot集成webSocket能启动,但是打包不了war
1.pom.xml少packing元素 https://www.cnblogs.com/zeussbook/p/10790339.html 2.SpringBoot项目中增加了WebSocket功能无 ...
- Appium 基于控件左滑操作
def swipe_ele_left(self, ele, dur=800): """ 基于控件元素左滑操作 :param ele: 控件元素 :param dur: 在 ...
- VS2010 安装boost库
1.下载boost库 boost官网:www.boost.org,目前最新的版本是1.64,直接下载地址:https://dl.bintray.com/boostorg/release/1.64.0/ ...
- c# asp.net 实现分页(pager)功能
分页PagerHelper辅助类 using System;using System.Web; public class PagerHelper { #region 获取分页的Html代码 /// & ...
- Linux学习之如何让普通用户获得ROOT权限
https://blog.csdn.net/qq_41940950/article/details/81044594
- Jfinal初次尝试及Jetty使用相关问题
Jetty介绍 Jetty官网:http://www.eclipse.org/jetty/ 参考:Jetty使用教程(一)--开始使用Jetty 1. 使用 参考上面文档,但是有些更新: echo $ ...