A - Wireless Network
#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的更多相关文章
- [并查集] POJ 2236 Wireless Network
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 25022 Accepted: 103 ...
- POJ 2236 Wireless Network(并查集)
传送门 Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 24513 Accepted ...
- poj 2236:Wireless Network(并查集,提高题)
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 16065 Accepted: 677 ...
- 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 ...
- Wireless Network
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 19626 Accepted: 8234 De ...
- POJ 2236 Wireless Network (并查集)
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 18066 Accepted: 761 ...
- POJ 2236 Wireless Network (并查集)
Wireless Network 题目链接: http://acm.hust.edu.cn/vjudge/contest/123393#problem/A Description An earthqu ...
- Wireless Network(POJ 2236)
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 20724 Accepted: 871 ...
- POJ - 2336 Wireless Network
Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have ...
- POJ2236 Wireless Network 并查集简单应用
Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have ...
随机推荐
- mongodb学习之:聚合
@font-face { font-family: "Times New Roman"; }@font-face { font-family: "宋体"; }p ...
- Linux就该这么学--命令集合6(打包压缩文件、文件查询搜索命令)
1.tar命令用于对文件打包压缩或解压:(tar [选项] [文件]) 打包并压缩文件:tar -czvf 压缩包名.tar.gz 文件名 解压并展开压缩包:tar -xzvf 压缩包名.tar.gz ...
- sudo出现unable to resolve host
是因为/etc/hosts下的主机名和/etc/hostname下的主机名不一致所导致的错误,将两个改为一致即可
- Linux-正则表达式学习(精)
正则表达式30分钟入门教程 来园子之前写的一篇正则表达式教程,部分翻译自codeproject的The 30 Minute Regex Tutorial. 由于评论里有过长的URL,所以本页排版比较混 ...
- BestCoder Round #92 1002 Count the Sheep —— 枚举+技巧
题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=748&pid=1002 题解: 做题的时候只是想到 ...
- C#评分小系统练习
一个经理类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sy ...
- 【转】看C++文档的小知识
转载:http://www.ggv.com.cn/forum/clib/ctype/isspace.html 函数isspace 原型:extern int isspace(int c); 用法 ...
- H3C-端口镜像
本地端口镜像配置举例 配置Switch: <Sysname> system-view [Sysname] mirroring-group 1 local # 创建本地镜像组 [Sysnam ...
- 字面量(literal)与 C 语言复合字面量(compound literals)
在计算机科学中,字面量(literal)是用于表达源代码中一个固定值的表示法(notation)(字面量是相对变量常量等定义的,无论是常量还是变量,其值在某一时刻总是确定的,只是变量可以反复赋值.刷新 ...
- python+Django实现Nagios自动化添加监控项目
最近机房刚上了一批机器(有100台左右),需要使用Nagios对这一批机器进行监控.领导要求两天时间完成所有主机的监控.从原来的经验来看,两天时间肯定完成不了.那怎么办?按照之前的想法,肯定是在nag ...