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 ...
随机推荐
- UI标签库专题四:JEECG智能开发平台 Upload(上传标签)
1. Upload(上传标签) 1.1. 參数 属性名 类型 描写叙述 是否必须 默认值 id string 上传控件唯一标示 是 null name string 控件name 是 null ...
- Decorator Pattern
1.Decorator 模式通过组合的方式提供了一种给类增加职责(操作)的方法. 2.Decorator模式结构图 3.实现 #ifndef _DECORATOR_H_ #define _DECORA ...
- indexDB操作(部分方法不太会使用)
<script type="text/javascript"> //打开数据库 function openDB(name,version){ var version = ...
- eval函数用法
JavaScript 全局对象 定义和用法 eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码. 语法 eval(string) 参数 描述 string 必需.要计算的字 ...
- LightOJ1197 Help Hanzo —— 大区间素数筛选
题目链接:https://vjudge.net/problem/LightOJ-1197 1197 - Help Hanzo PDF (English) Statistics Forum Tim ...
- True(False) Positives (Negatives), 召回率和精度定义
True Positive (真正, TP)被模型预测为正的正样本: True Negative(真负 , TN)被模型预测为负的负样本 : False Positive (假正, FP)被模型预测为 ...
- BestCoder7 1001 Little Pony and Permutation(hdu 4985) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4985 题目意思:有 n 个数,对于第 i 个数给出 σ(i) 的值.求出互不相交的循环的个数,并输出每 ...
- codeforces B. Eugeny and Play List 解题报告
题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...
- html5--4-4 audio元素/格式的转换
html5--4-4 audio元素/格式的转换 学习要点 掌握audio元素的用法 视频/音频文件的格式转换 当前,audio 元素支持三种音频格式: Ogg 免费, 支持的浏览器:Firefox. ...
- 烂笔头——JAVA.String
人们说 Sting+ 的效率很低 String+的编译步骤是: new StringBuilder() new String.valueof() StringBuilder.<init> ...