题目链接: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. POI 读大文件日志

    POI的三个目录 usermodel 包含很多类,方便用户使用,但是占用内存大 eventusermodel 使用xml的SAX事件解析,XSSFReader创建时必须使用OPCPackage,pkg ...

  2. jupyter notebook自动补全功能实现

    Jupyter notebook使用默认的自动补全是关掉的.要打开自动补全,需修改默认配置. 命令行中输入:ipython profile create 以上命令会在~/.ipython/profil ...

  3. Zabbix sql注入漏洞脚本执行反弹shell

    exp检测是否存在SQL注入漏洞root@ubuntu:~# python zabbix.py http://ip:9090/+------------------------------------ ...

  4. my18_mysql中的几个超时时间

    连接的超时时间 set global interactive_timeout=120;set global wait_timeout=120; 该连接指类似应用访问数据库的连接,可以是查询.DML.D ...

  5. ubuntu 启动 ssh 服务

    $ sudo service ssh start $ sudo /etc/init.d/ssh start 重启 $ sudo /etc/init.d/ssh restart $ sudo servi ...

  6. ES6多行字符串+模板字符串

    多行字符串 最新的ES6标准新增了一种多行字符串的表示方法,用反引号 ` ... ` 表示: 'use strict'; // 如果浏览器支持模板字符串,将会替换字符串内部的变量: var name ...

  7. NGINX编译选项

    一.减小编译后的文件大小Nginx源码文件解压后,找到auto/cc/gcc文件,注释或删除:# debugCFLAGS= "CFLAGS -g"即可取消debug模式.二:为特定 ...

  8. PHP会话管理

    Session使用 在每个页面中使用session之前,必须使用session_start() 在每个session中都可以使用$_SESSION这个全局数组,在页面必须调用session_start ...

  9. 《nginx 四》双机主从热备

    lvs+keepalived+nginx实现高性能负载均衡集群 LVS作用 LVS是一个开源的软件,可以实现传输层四层负载均衡.LVS是Linux Virtual Server的缩写,意思是Linux ...

  10. Machine learning preface

    Machine learning Preface Definition T: Task E: Experience P: Performance Sequence: T -> E -> P ...