Wireless Network

用Keil5给CH552G编程:手把手配置8051开发环境+LED闪烁实战 本文详细介绍了如何使用Keil5为CH552G单片机配置8051开发环境,并完成LED闪烁实战。从获取必要软件、安装WCH器件库到创建工程、编写程序及烧录,手把手指导开发者避开常见陷阱,特别适合从STC转向CH552G的开发者。 阅读详情

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
有一堆电脑,给出坐标,然后距离不超过d才可以沟通。一开始电脑都是坏的,o操作代表修电脑,s操作判断x与y是否可以联通。
看了数据范围,修的时候判断他周围是否有电脑连上,查询都是简单的并查集。还有,一开始用vector预处理一下,把距离之内的电脑放进去,不然就算修好,也不会联通。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int x[1005], y[1005], p[1005];
vector<int>gather[1005];
bool leap[1005];
int dis(int i, int j)
{
    return (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
}
void init(int n)
{
    for (int i = 1; i <= n; i++)
        p[i] = i;
}
int find(int x)
{
    return x == p[x] ? x : p[x] = find(p[x]);
}
int main()
{
#ifdef LOCAL
    freopen("C:\\Users\\巍巍\\Desktop\\in.txt", "r", stdin);
    //freopen("C:\\Users\\巍巍\\Desktop\\out.txt","w",stdout);
#endif // LOCAL
    int n, d;
    scanf("%d%d", &n, &d);
    init(n);
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &x[i], &y[i]);
    getchar();
    for (int i = 1; i <= n; i++)gather[i].clear();
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (dis(i, j) <= d*d)
            {
                gather[i].push_back(j);
                gather[j].push_back(i);
            }
        }
    }
    for (int i = 1; i <= n; i++)leap[i] = false;
    char c;
    while (scanf("%c", &c) != EOF)
    {
        if (c == 'O')
        {
            int pin;
            scanf("%d", &pin); getchar();
            leap[pin] = true;
            for (int i = 0; i < gather[pin].size(); i++)
            {
                if (!leap[gather[pin][i]])continue;
                int pp, pi;
                pp = find(pin); pi = find(gather[pin][i]);
                if (pp != pi)
                {
                    p[pi] = pp;
                }
            }
        }
        else
        {
            int pin, q;
            scanf("%d%d", &pin, &q); getchar();
            pin = find(pin); q = find(q);
            if (pin == q)
                printf("SUCCESS\n");
            else
                printf("FAIL\n");
        }
    }
    return 0;
}
用 ADT 的 RAP Generator 把 RAP 栈一键搭起来:从表到可预览的 OData V4 应用 摘要 SAP RAP Generator 工具能显著提升开发效率,通过一键生成从数据库表到完整 OData UI Service 的全套对象(包括 CDS、Behavior、Service Definition 等)。该工具特别适用于原型验证和标准化应用开发,可节省 60% 以上的基础编码时间。使用时需注意: 表设计需包含关键管理字段(如 last_changed 时间戳) 向导配置决定分层架构和命名规范 生成结果包含可立即预览的 Fiori Elements 界面 后续可专注于业务逻辑增强(校验、权限等) 阅读详情

相关推荐

新卡尝鲜记:RTX 5070Ti适配PyTorch生态的实战避坑指南

本文分享了RTX 5070Ti适配PyTorch生态的实战经验。针对CUDA 12.8兼容性问题,详细介绍了安装PyTorch Nightly版本、手动编译xformers库以及寻找PyTorch3D第三方预编译包的完整流程与解决方案,帮助用户快速搭建可用的深度学习开发环境。

weixin_29094775的博客 287

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

智能座舱-语音交互系统

从什么是智能座舱、智能座舱的发展驱动因素、智能座舱的构成要素三个方面梳理我对智能座舱的基础认识之后,为了加深“智能座舱产品入门”课程中语音交互部分知识的理解,我从什么是语音交互、语音交互的底层技术、智能座舱的语音交互等方面,对智能座舱语音交互系统相关的知识进行了梳理与总结。

GUOSA0928的博客 1440

并查集-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

anaconda的conda国内加速镜像源(pytorch 快速安装)

最近清华源不太好使了,所以推荐中科大镜像源,如下 1.还原原始通道 conda config --remove-key channels 2.

qq_41719643的博客 2万+

RK3576开发板ROS2部署实战:从Buildroot配置到Hello World Demo

本文详细介绍了在RK3576开发板上部署ROS2的完整实战流程。从Buildroot工程配置、集成ROS2依赖,到搭建Docker交叉编译环境、处理编译难题,最终完成系统镜像打包并在板端成功运行Talker-Listener Demo。该指南旨在帮助开发者深入理解嵌入式机器人系统的构建链,实现从底层到应用的完全掌控。

mac99的博客 1149

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

超详细Matlab R2021a免费安装教程(附安装包)

Matlab是一种高级技术计算语言和交互式环境,用于算法开发、数据可视化和数值计算。它集成了数学、工程和科学计算的丰富函数库,提供了强大的数据分析和绘图工具。Matlab还支持并行计算和大规模数据处理,适用于各种领域,如信号处理、图像处理、控制系统、机器学习等。

waicsdn_haha的博客 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的博客 559

WinForm布局

登录模板页面UILoginForm

m0_71541781的博客 469

Qt 5.15.2静态编译避坑实录:MinGW 32位版从源码到Creator配置的全流程踩坑总结

本文详细介绍了Qt 5.15.2 MinGW 32位版本的静态编译全流程,包括环境准备、配置参数优化、编译过程监控及安装后配置。重点解决了静态编译中的常见问题,如参数顺序敏感、路径引号问题等,并提供了性能对比实测数据,帮助开发者高效完成静态编译。

weixin_26749245的博客 271

【Part 5】wireless networking

我们的目标:原则:无线网络通信和移动性CDMA802.11 wi-fi蓝牙,3G协议概述:无线通信架构CDMAWLAN1、无线网络简介无线束缚,自由5A通信可以实现任何人,无论何时何地,无论如何,任何事无线网络分类:从覆盖范围:WPAN无线个人区域网络WLAN-无线局域网WMAN / WWAN-无线城域网/无线广域网从应用程序:WSN无线传感器网络WMN-无线网状网络WWN无线磨损网络WBAN无线...

yeler082的博客 2216

Aurix TC3xx系列MCU DMA模块配置方法(二)

本文主要基于英飞凌Aurix TC3xx系列MCU,通过EB tresos配置工具,介绍DMA驱动模块的配置方法。

m0_38045338的博客 2850

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

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Wireless Network(百练,POJ)

Wireless Network(百练,POJ)

zht2002的博客 497

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

[POJ 2236]Wireless Network[并查集]

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

闲停 509

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

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

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

coocner的博客 286
上一篇: Cube Stacking
下一篇: A Bug's Life
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值