【并查集】POJ2236-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 attacked, all computers in the network were all broken. The c…
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…
链接: http://poj.org/problem?id=2236 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#problem/A 代码: #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> #include<iostream>…
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…
http://poj.org/problem?id=2236 由于发生了地震,有关组织组把一圈电脑一个无线网,但是由于余震的破坏,所有的电脑都被损坏,随着电脑一个个被修好,无线网也逐步恢复工作,但是由于硬件的限制,一台电脑和另一台电脑能够相连当他们之间的距离小于d,或者还有一台电脑当中介,分别与两台电脑相连. 在修复的过程中,工作者会有两种操作,修复电脑和询问电脑a和电脑b是否相连.当询问的时候输出答案. 因为输入数据很大,需要快速判断电脑a和电脑b相连,所以自然想到用并查集. 初始时候 全部电…
题目地址:http://poj.org/problem?id=2236 题目大意:n台电脑都坏了,只有距离小于d且被修好的电脑才可以互相联系,联系可传递.输入n和d,n个点的坐标x y.两个操作:O x表示把电脑x修好了,S x y表示询问x和y能否联系. 思路:并查集把能互相联系的电脑都放到同一个集合里(联系可以互相传递),查询的时候只要看x和y是否在一个集合就行了. 另设置两个数组visit[x]表示x是否被修好,dis[x][y]表示x和y之间的距离是否符合要求[先预处理任意两个点之间的距…
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…
题目:Wireless Network 题意:给定n台已损坏计算机的位置和计算机最远通信距离d,然后分别根据命令执行以下两种操作: "O p" (1 <= p <= N) :表示修理计算机p: "S p q" (1 <= p, q <= N) :表示检测计算机p和计算机q能否通信. 输出:能通信则输出"SUCCESS",否则输出"FAIL" 题解: 带权并查集还是那个重要的知识点——关系. 此题,我们使…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 26131   Accepted: 10880 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap compute…
网址:http://poj.org/problem?id=2236 题意:有n台坏的电脑,如果每两台电脑的距离不能超过d,那么这两台电脑有联系,用字符串O 表示标记第x台电脑维修了,用S判断从X到y是否有联系... 题解:用并查集记录和查找每个点的父亲节点,每次输入的同时遍历该点和其他点是否有联系(即距离小于等于的)..... #include<iostream> #include<cstdio> #include<cstring> using namespace st…
解题思路:简单并查集,注意时间限制是10000MS,每次进行O操作之后,   进行一次for循环,进行相关调整.同时注意输入输出格式,见代码: #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; ; int father[maxn], vis[maxn]; struct node{ double x, y; //此处用doubl…
[题目大意] 已知每一台电脑只能与它距离为d的电脑相连通,但是两台电脑间可以以第三台作为媒介连接.现在电脑全被损坏.每次可以进行两个操作中的一个,或是修好一台电脑,或是查询两台电脑是否连通. [思路] 显然是并查集.每次修好一台新电脑,就与之前修好的每一台电脑进行判断,距离在d以内就合并. #include<iostream> #include<cstdio> #include<cstring> using namespace std; +; int n,d; int…
水题 #include<cstdio> #include<cstring> #include<queue> #include<set> #include<cstdlib> #include<algorithm> #include<vector> #include<cmath> using namespace std; typedef long long LL; typedef pair<int,int&g…
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基础并查集★2120 Ice_cream's world I 基础并查集★212…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 39772   Accepted: 16479 题目链接: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 这接翻译了 Descriptions 地震发生在东南亚.ACM(亚洲合作医疗团队)已经与膝上电脑建立了无线网络,但是一次意外的余震袭击,网络中的所有计算机都被打破了.计算机一个接一个地修复,网络逐渐开始工作.由于硬件限制,每台计算机只能直接与距离它不远的计算机进行通信.但是,每台计算机都可以被视为两台其他计算机之间通信的中介,也就是说,如果计算机A和计算机B可以直接通信,或者计算机C可以与A和A进行通信,则计算机A和计算机B可以进行通信. B. 在修复网络的过程…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 25022   Accepted: 10399 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap compute…
传送门  Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 24513   Accepted: 10227 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap co…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 16065   Accepted: 6778 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computer…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 18066   Accepted: 7618 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computer…
Wireless Network 题目链接: http://acm.hust.edu.cn/vjudge/contest/123393#problem/A 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 aft…
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…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 36363   Accepted: 15086 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap compute…
POJ 2236 Wireless Network http://poj.org/problem?id=2236 题目大意: 给你N台损坏的电脑坐标,这些电脑只能与不超过距离d的电脑通信,但如果x和y均能C通信,则x和y可以通信.现在给出若干个操作, O p 代表修复编号为p的电脑 S p q代表询问p和q是不是能通信. 思路: 并查集即可.. 如果修复了一台电脑,则把与它相连距离不超过d的且修复了的放在一个集合里面. #include<cstdio> #include<cstring&…
题意: 一次地震震坏了所有网点 现在开始修复它们 有N个点 距离为d的网点可以进行通信 O p   代表p点已经修复 S p q 代表询问p q之间是否能够通信 思路: 基础并查集 每次修复一个点重新刷一边图就行了 /* *********************************************** Author :Sun Yuefeng Created Time :2016/11/1 15:40:35 File Name :food.cpp ******************…
链接:http://poj.org/problem?id=2236 题意: 有一个计算机网络,n台计算机全部坏了,给你两种操作: 1.O x 修复第x台计算机 2.S x,y 判断两台计算机是否联通 联通的条件: 两台都修复好了,求距离小于d 思路: 数据很小,我们可以没修复一台就直接枚举已经修复的计算机找到距离小于d的,放到一个并查集里,查询的话直接查询是否再同一个并查集里就好了 实现代码: //while(scanf("\n%c", &ope) != EOF) #inclu…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 16832   Accepted: 7068 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computer…
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…
#include<iostream> #include<vector> #include<string> #include<cmath> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; int n, d; ][]; struct Point { double x, y; }cur[]; ]; int findRoot(i…
题意是判断两台电脑是否能通讯,两台修好的电脑距离在指定距离内可直接通讯,且两台修好的电脑能通过一台修好的电脑间接通讯.代码如下: #include <iostream> #include <cstring> #include <cstdio> using namespace std; int father[1005]; struct Coord //电脑坐标 { int x; int y; } coo[1005]; struct Repair //已修复好的电脑的坐标和…