题目链接:http://poj.org/problem?id=2236

思路很简单,傻逼的我输出写成了FALL,然后遍历的时候for循环写错了,还好很快我就Debug出来了。

#include <stdio.h>

struct Point
{
int x,y;
} points[]; int father[];
bool vis[]= {false}; int Find_Set (int x)
{
if(x!=father[x])
father[x] = Find_Set(father[x]);
return father[x];
} int main()
{ int N,d;
scanf("%d%d",&N,&d); for(int i=; i<=N; i++)
father[i] = i; for(int i=; i<=N; i++)
scanf("%d%d",&points[i].x,&points[i].y);
getchar(); char ch;
while(scanf("%c",&ch)!=EOF)
{
getchar();
int n,m;
if(ch=='O')
{
scanf("%d",&n);
getchar();
vis[n] = true; for(int i=; i<=N; i++)
{
if(i!=n&&vis[i])
{
int tx = points[n].x - points[i].x;
int ty = points[n].y - points[i].y;
if(tx*tx+ty*ty<=d*d)
{
int fx = Find_Set(i);
int fy = Find_Set(n); if(fx!=fy)
father[fy] = fx;
}
}
}
}
else
{
scanf("%d%d",&n,&m);
getchar(); int fx,fy;
fx = Find_Set(n);
fy = Find_Set(m);
if(fx!=fy)
printf("FAIL\n");
else printf("SUCCESS\n"); }
} return ;
}

Poj(2236),简单并查集的更多相关文章

  1. POJ 2236 (简单并查集) Wireless Network

    题意: 有n个电脑坏掉了,分别给出他们的坐标 有两种操作,可以O x表示修好第x台电脑,可以 S x y表示x y是否连通 两台电脑的距离不超过d便可连通,两台电脑是连通的可以直接连通也可以间接通过第 ...

  2. POJ 2524 (简单并查集) Ubiquitous Religions

    题意:有编号为1到n的学生,然后有m组调查,每组调查中有a和b,表示该两个学生有同样的宗教信仰,问最多有多少种不同的宗教信仰 简单并查集 //#define LOCAL #include <io ...

  3. poj 2236【并查集】

    poj 2236 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical t ...

  4. POJ 2492 (简单并查集) A Bug's Life

    题意:有编号为1~n的虫子,开始假设这种昆虫是异性恋.然后已知xi 和 yi进行交配,根据已知情况分析能否推理出其中是否有同性恋 这道题和 POJ 1182 食物链 十分相似,不过在更新与父节点关系的 ...

  5. poj 1611 简单并查集的应用

    #include<stdio.h> #define N 31000 int pre[N]; int find(int x) { if(x!=pre[x])     pre[x]=find( ...

  6. poj1611 简单并查集

    The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 32781   Accepted: 15902 De ...

  7. 1213 How Many Tables(简单并查集)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1213 简单并查集,统计单独成树的数量. 代码: #include <stdio.h> #i ...

  8. 【简单并查集】Farm Irrigation

    Farm Irrigation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Tot ...

  9. ACM_“打老虎”的背后(简单并查集)

    “打老虎”的背后 Time Limit: 2000/1000ms (Java/Others) Problem Description: “习大大”自担任国家主席以来大力反腐倡廉,各地打击贪腐力度也逐步 ...

随机推荐

  1. 使用xUnit为.net core程序进行单元测试

      第1部分: http://www.cnblogs.com/cgzl/p/8283610.html 第2部分: http://www.cnblogs.com/cgzl/p/8287588.html ...

  2. Object与String

    Object转为String的几种形式 在java项目的实际开发和应用中,常常需要用到将对象转为String这一基本功能.本文将对常用的转换方法进行一个总结.常用的方法有Object.toString ...

  3. 转 Python 多进程multiprocessing.Process之satrt()和join()

    1. https://blog.csdn.net/wonengguwozai/article/details/80325745 今天项目中涉及到了使用多进程处理数据,在廖雪峰的python教程上学习了 ...

  4. 转 Python-IndexError: list index out of range

    https://www.cnblogs.com/2bjiujiu/p/9063864.html Error:IndexError: list index out of range Where? 对Py ...

  5. SpringMVC---彻底解决/和/*的问题!到底该用哪一个?

    出处: https://blog.csdn.net/sinat_33921105/article/details/81951156 在web开发中我们经常会遇到/和/*的问题,有的时候稍不注意就容易忘 ...

  6. Jenkins遇到哪些坑~

    1Jenkins关闭和重启实现方式. 1.关闭Jenkins ​ 只需要在访问jenkins服务器的网址url地址后加上exit.例如我jenkins的地址http://localhost:8080/ ...

  7. JS中==、===和Object.is()的区别

    JS中==.===和Object.is()的区别 首先,先粗略了解一下这三个玩意儿: ==:等同,比较运算符,两边值类型不同的时候,先进行类型转换,再比较: ===:恒等,严格比较运算符,不做类型转换 ...

  8. Spark机器学习库(MLlib)官方指南手册中文版

    中文https://blog.csdn.net/liulingyuan6/article/details/53582300 https://yq.aliyun.com/articles/608083 ...

  9. shell 命令下载软件 安装软件

    下载命令:wget URL地址 wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noa ...

  10. RNN学习资料

    1. Recurrent Neural Networks Tutorial, Part 2 – Implementing a RNN with Python, Numpy and Theano htt ...