Wireless Network

wireless network OPNET实现节点的无线通信,以及移动节点的干扰检验信噪比 立即下载

http://poj.org/problem?id=2236

Description
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the network were all broken. The computers are repaired one by one, and the network gradually began to work again. Because of the hardware restricts, each computer can only directly communicate with the computers that are not farther than d meters from it. But every computer can be regarded as the intermediary of the communication between two other computers, that is to say computer A and computer B can communicate if computer A and computer B can communicate directly or there is a computer C that can communicate with both A and B.

In the process of repairing the network, workers can take two kinds of operations at every moment, repairing a computer, or testing if two computers can communicate. Your job is to answer all the testing operations.

Input
The first line contains two integers N and d (1 <= N <= 1001, 0 <= d <= 20000). Here N is the number of computers, which are numbered from 1 to N, and D is the maximum distance two computers can communicate directly. In the next N lines, each contains two integers xi, yi (0 <= xi, yi <= 10000), which is the coordinate of N computers. From the (N+1)-th line to the end of input, there are operations, which are carried out one by one. Each line contains an operation in one of following two formats:
1. “O p” (1 <= p <= N), which means repairing computer p.
2. “S p q” (1 <= p, q <= N), which means testing whether computer p and q can communicate.

The input will not exceed 300000 lines.

Output
For each Testing operation, print “SUCCESS” if the two computers can communicate, or “FAIL” if not.

Sample Input

4 1
0 1
0 2
0 3
0 4
O 1
O 2
O 4
S 1 4
O 3
S 1 4

Sample Output

FAIL
SUCCESS

题意:有N台电脑,知道他们的坐标,并且如果两台之间的距离小于d的话,并且这两台都修好了就可以联网,并且可以通过其他电脑连接。简单并差集。

解题思路: 这是一个简单并差集题目。每次修复一台电脑后就将其标记成true,让后遍历一次判断是否有有与其连同的且他们的距离是否满足能修复距离,如果有将其父节点置成同一个。查询时只要查询他们是否有共同的父节点。

复杂度分析:时间复杂度:o(n*x)x为输入的指令条数

#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=10000+5;
int N,d;
char op[10];
int par[maxn],ranks[maxn];
bool vis[maxn];//代表着是否已经修复了电脑,电脑是否正常
struct co {
    int x,y;
} coh[maxn];
void init(int sizes) {
    for(int i=0; i<=sizes; i++) {
        par[i]=i;
        ranks[i]=1;
    }
}
int find(int x) {
    return par[x]==x?x:par[x]=find(par[x]);
}
bool same(int x,int y) {
    return find(x)==find(y);
}
bool judge(int x,int y) {
    return pow((coh[x].x-coh[y].x),2.0)+pow((coh[x].y-coh[y].y),2.0)<=pow(d,2.0);//判断距离是否符合条件
}
void unite(int x,int y) {
    x=find(x);
    y=find(y);
    if(x==y)return ;
    if(ranks[x]>ranks[y]) {
        par[y]=x;
    } else {
        par[x]=y;
        if(ranks[x]==ranks[y])ranks[x]++;
    }
}
int main() {
    int c,e;
    scanf("%d%d",&N,&d);
    init(N);
    memset(vis,false,sizeof(vis));
    for(int i=1; i<=N; i++) {
        scanf("%d%d",&coh[i].x,&coh[i].y);
    }
    while(~scanf("%s",op)) {
        if(op[0]=='O') {
            scanf("%d",&c);
            vis[c]=true;
            for(int i=1; i<=N; i++) {
                if(vis[i]&&judge(c,i)) {//与其他的电脑进行联系的前提是他们是好的,如果不好就连接不上
                    unite(c,i);
                }
            }
        } else {
            scanf("%d%d",&c,&e);
            if(vis[c]&&vis[e]&&same(c,e)) {//是否通信,要看电脑是否已经修复完成
                printf("SUCCESS\n");
            } else printf("FAIL\n");
        }
    }
    return 0;
}
wireless networkinf wireless and Mobile Networks 立即下载

相关推荐

【基于大模型 + FAISS 的本地知识库与智能 PPT 生成系统:从架构到实现】

本文介绍了一个基于大模型(Ollama+DeepSeek)和FAISS向量数据库的本地知识库与智能PPT生成系统。该系统采用前后端分离架构,包含文档管理、向量检索、PPT生成等核心模块,可实现文档智能解析、语义检索和结构化PPT自动生成。通过MVC设计模式,系统实现了从文档上传、向量存储到内容检索、PPT生成的全流程自动化,有效解决了企业知识管理效率低下的问题。架构设计清晰,功能模块完备,为企业和个人提供了高效的文档处理与二次创作解决方案。

聚焦大数据、AI、数据库三大核心领域,分享 Flink/Spark 实时计算、数仓架构设计、AI 模型落地、数据库性能调优的实战干货,附可直接运行的源码与方案。提供企业技术内训、项目咨询与定制化服务,助力开发者与企业高效搞定数智技术难题。 1599

POJ-Wireless Network(并查集基础)

原题链接:http://poj.org/problem?id=2236 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unex...

nuoyanli的博客 1821

Excel VBA+Adobe Acrobat Pro PDF发票识别全流程(附避坑指南)

本文详细介绍了如何利用Excel VBA与Adobe Acrobat Pro的API接口,构建一套企业级PDF发票智能识别与处理系统。内容涵盖从环境配置、核心文本提取原理、数据解析清洗到工程化脚本设计的全流程,并针对密码区干扰、不征税发票等常见问题提供避坑指南,旨在帮助财务人员和开发者实现高效、精准的财务数据处理自动化。

weixin_29207439的博客 347

并查集-Wireless Network POJ - 2236

并查集-Wireless Network POJ - 2236 题目: An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftersh...

njuptACMcxk的博客 431

YOLOv11 改进策略:引入 NWD 损失函数提高小目标检测精度

YOLO(You Only Look Once)是一种实时目标检测算法,能够有效地预测图像中多个物体的边界框和类别概率。其高效性使它成为自动驾驶、视频监控等领域的理想选择。NWD 是一种基于 Wasserstein 距离的损失函数,其通过归一化处理,更好地评估预测框和真实框之间的几何偏差。这种方法不仅仅关注重叠区域,而且考虑中心点和尺度信息,提高了对小目标的敏感度。

走向CTO的路上... 2001

告别拼音!用VSCode+Dosbox-X搞定汇编语言课程设计里的中文姓名显示

本文详细介绍了如何利用VSCode和Dosbox-X解决汇编语言课程设计中中文姓名显示的问题。通过配置开发环境、理解GB2312编码及正确使用汇编指令,学生可以告别拼音显示,实现中文字符的正确输出。文章还提供了完整的代码示例和常见问题排查方法,帮助读者快速掌握这一实用技能。

weixin_30872337的博客 424

POJ -2236 Wireless Network

题目: Wireless Network An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked,...

仅余我与暮色平分此世界 443

基于STM32设计的老人防摔倒报警设备(OneNet)_65

本文设计了一种基于STM32单片机的智能老人防摔倒报警设备。该系统结合MPU6050陀螺仪传感器实时监测老人的姿态变化,检测摔倒事件;通过SIM800C通信模块发送短信通知紧急联系人,并将GPS定位信息上传至云端平台,确保家属能够及时了解老人的准确位置。

1万+

A - Wireless Network

An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...

weixin_43892738的博客 560

SAP MM ME21N保存前检查增强

想在ME21N保存前做一些数据检查, 可以做一个增强功能,  运行 CMOD 新增,   增强接口 输入 MM06E005  (  EXIT_SAPMM06E_012 ) ,在 NCLUDE ZXM06U43 .  里写代码功能。  例子如下: *&---------------------------------------------------------------------*

heng0757的专栏 1万+

SpringBoot项目搭建

SpringBoot项目搭建

私信可回答各种问题~ 1020

E - Wireless Network(并查集)

E - Wireless Network(并查集) An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock att

galesaur_wcy 478

YOLOv11改进策略【卷积层】| CVPR-2024 PKI Module 获取多尺度纹理特征,适应尺度变化大的目标

PKI Module是。

Limiiiing的博客 2705

POJ - 2236Wireless Network-并查集

POJ - 2236 Wireless Network Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u SubmitStatus Description An earthquake t...

aoe41606的博客 143

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Wireless Network(百练,POJ)

Wireless Network(百练,POJ)

zht2002的博客 497

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

[POJ 2236]Wireless Network[并查集]

题目链接:[POJ 2236]Wireless Network[并查集] 题意分析: 电脑网络全部被破坏了,如今能做的是两个操作:一、修复某个电脑;二、查询两个电脑间能否交流。两台电脑能交流的情况是:两台都被修复了,并且两台相距小于d米或者两台之间能借由其它电脑相互联系 解题思路: 当某台电脑被修复时,遍历所有它能连接到的结点,如果所连接结点是被修复的,就将它归入到同一集合。这样每次查询的

闲停 509

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

POJ 2236 Wireless Network(并查集)

题目链接: POJ 2236 Wireless Network 题意:有N台损坏了电脑,给出N台电脑的坐标,已知当两个修好的电脑间的距离小于等于d时,两台修好的电脑可以连通。 两台连通的电脑之间可以有若干台电脑作为桥梁。 有两种操作:O,P:修好第P台电脑 S P,Q:询问第P台电脑和第Q台电脑是否连通。 对于每一条询问如果连通输出“SUCCESS”,未连通输出“FAIL”。 分析:

ramay7 450

POJ 2236 Wireless Network

Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 18917 Accepted: 7957 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team)

小寒 465
上一篇: http://acm.hdu.edu.cn/showproblem.php?pid=1203(背包问题)
下一篇: Information Sharing
hellohelloC
博客等级 码龄12年 15粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值