题意:

一次地震震坏了所有网点 现在开始修复它们

有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
************************************************ */ #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<bitset>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<queue>
#include<list>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e3+;
const int mod=1e7+;
int dx[]= {,,,-,,-,,-};
int dy[]= {,-,,,-,,,-}; int n,d;
int father[maxn];
bool vis[maxn]; struct network
{
int x,y;
int dis(network a)
{
int xx=a.x-x;
int yy=a.y-y;
return xx*xx+yy*yy;
}
}net[maxn]; bool judge(network a,network b)
{
if(a.dis(b)>d*d) return false;
return true;
} int find(int x)
{
if(father[x]!=x) father[x]=find(father[x]);
return father[x];
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%d%d",&n,&d);
for(int i=;i<maxn;i++)
vis[i]=false,father[i]=i;
for(int i=;i<=n;i++)
scanf("%d%d",&net[i].x,&net[i].y);
getchar();
char str[];
int p,q;
while(~scanf("%s",str))
{
if(str[]=='O')
{
scanf("%d",&p);
vis[p]=true;
for(int i=;i<=n;i++)
{
if(i==p||!vis[i]) continue;
if(judge(net[p],net[i]))
{
father[find(p)]=find(i);
}
}
}
else
{
scanf("%d%d",&p,&q);
if(find(p)==find(q)) printf("SUCCESS\n");
else printf("FAIL\n");
}
}
return ;
}

[ An Ac a Day ^_^ ] [kuangbin带你飞]专题五 并查集 POJ 2236 Wireless Network的更多相关文章

  1. [kuangbin带你飞]专题五 并查集

    并查集的介绍可以看下https://www.cnblogs.com/jkzr/p/10290488.html A - Wireless Network POJ - 2236 An earthquake ...

  2. [kuangbin带你飞]专题五 并查集 A - Wireless Network

    An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wi ...

  3. [ An Ac a Day ^_^ ] [kuangbin带你飞]专题四 最短路练习 POJ 3259 Wormholes

    SPFA求负环 模板题 记得每组处理之前clear vector /* *********************************************** Author :Sun Yuef ...

  4. [kuangbin带你飞]专题四 最短路练习 POJ 3268 Silver Cow Party

    题意: 在一个有向图中求n头牛从自己的起点走到x再从x走回来的最远距离 思路一开始是暴力跑dij…… 讲道理不太可能…… 然后就百度了一下 才知道把矩阵转置的话就只需要求两次x的单源最短路…… /* ...

  5. [kuangbin带你飞]专题四 最短路练习 POJ 1797 Heavy Transportation

    求每条道路的最大承载量 和上一道题差不多 就是松弛的规则从最大值变成了最小值 /* *********************************************** Author :Su ...

  6. [kuangbin带你飞]专题四 最短路练习 POJ 2253 Frogger

    求第一个点到第二个点的所有通路上最长的边 dijkstra的变形 每次松弛的是每条边通路上的的最长的边 WA了好几次是因为用了%lf 改成%f就过了…… /* ******************** ...

  7. [ An Ac a Day ^_^ ] [kuangbin带你飞]专题四 最短路练习 POJ 2387 Til the Cows Come Home

    求1到N的最短路 注意有重边 跑一遍dijkstra就行 /* *********************************************** Author :Sun Yuefeng ...

  8. [kuangbin带你飞]专题1-23题目清单总结

    [kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 Fli ...

  9. [kuangbin带你飞]专题十一 网络流

            ID Origin Title   34 / 81 Problem A POJ 3436 ACM Computer Factory   92 / 195 Problem B POJ 3 ...

随机推荐

  1. VC 编程ANSI环境下读写Unicode文件

    没有注意到文件编码的不同会产生这么多的问题,在动手以前查询了很多资料,在本博客中收藏了不少先辈的成果,在这里一并表示致敬!       关于ANSI和Unicode编码的原理在这里也不说了,主要讲下如 ...

  2. Entity Framework:如果允许模型处于非法状态,在某些场景下,记得清空DbContext

    Entity Framework:如果允许模型处于非法状态,在某些场景下,记得清空DbContext 背景 之前写过两篇文章介绍模型的合法性: DDD:关于模型的合法性,Entity.IsValid( ...

  3. notes/Set up development environment on windows

    恰好前几天买了个新笔记本, 15存 sony vaio, 终于从mac回到了windows. 不过作为(曾经的)*nix追随者, 没有bash真是寸步难行, 幸好windows8.x有了super s ...

  4. python 提供INI配置文件的操作 ConfigParser

    原文地址:http://www.cnblogs.com/pumaboyd/archive/2008/08/11/1265416.html 红色的为标注信息 +++++++++++++++++引用+++ ...

  5. python logging info -> 将服务请求记录输出

    在tornado 里面这样用 看看logging.warning() , logging.info() , 我们非常想用 zdaemon , 和 logging 将对系统的所有访问转换到服务器里面,作 ...

  6. SVN-钩子祥解与配置

    钩子脚本的具体写法就是操作系统中shell脚本程序的写法,请根据自己SVN所在的操作系统和shell程序进行相应的写作 所谓钩子就是与一些版本库事件触发的程序,例如新修订版本的创建,或是未版本化属性的 ...

  7. Big Data Ingestion and streaming product introduction

    Flume Flume isdistributed system for collecting log data from many sources, aggregating it,and writi ...

  8. 深入理解Java Proxy机制(转)

    动态代理其实就是java.lang.reflect.Proxy类动态的根据您指定的所有接口生成一个class byte,该class会继承Proxy类,并实现所有你指定的接口(您在参数中传入的接口数组 ...

  9. IFE-20 笔记

    将字符串按符号分割成数组 var str = 'aa,43,rt,55'; var arr = str.split(/[^0-9a-zA-Z\u4e00-\u9fa5]+/) //arr = [aa ...

  10. 【翻译】在Mac上使用VSCode创建你的第一个Asp.Net Core应用

    Setting Up Your Development Environment 设置你的开发环境 To setup your development machine download and inst ...