poj 2236 Wireless Network
来源:互联网 发布:苹果笔记本设计软件 编辑:程序博客网 时间:2024/06/05 14:28
http://poj.org/problem?id=2236
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <cmath>#include <cstdlib>#include <limits>#include <queue>#include <stack>#include <vector>#include <map>using namespace std;#define N 1100#define INF 0x3f3f3f3f#define PI acos (-1.0)#define EPS 1e-8struct node{ int x, y, t;}p[N];int n, d, vis[N];int Find (int x){ if (x != p[x].t) p[x].t = Find (p[x].t); return p[x].t;}void join (node p1, node p2){ int xx = Find (p1.t), yy = Find (p2.t); if (xx != yy && ((p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y) <= d * d)) p[xx].t = yy;}int main (){ while (cin >> n >> d) { for (int i=1; i<=n; i++) { p[i].t = i; cin >> p[i].x >> p[i].y; } memset (vis, 0, sizeof (vis)); char ch; int k, sa, en; while (cin >> ch) { if (ch == 'O') { cin >> k; vis[k] = 1; for (int i=1; i<=n; i++) if (vis[i] && i != k) join (p[k], p[i]); } else { cin >> sa >> en; if (Find (sa) == Find (en)) puts ("SUCCESS"); else puts ("FAIL"); } } } return 0;}
0 0
- poj 2236 Wireless Network
- poj 2236 Wireless Network
- poj 2236 Wireless Network
- POJ 2236 Wireless Network
- POJ-2236 Wireless Network
- poj 2236 Wireless Network
- POJ 2236 - Wireless Network
- poj 2236 Wireless Network
- POJ 2236 Wireless Network
- poj 2236 wireless network
- POJ--2236--Wireless Network
- POJ-2236-Wireless Network
- poj 2236 Wireless Network
- poj 2236 Wireless Network
- POJ 2236Wireless Network
- POJ 2236 Wireless Network
- POJ 2236 Wireless Network
- POJ 2236 Wireless Network
- 防SQL注入
- 持久化API(JPA)系列(六)实体关系映射(ORM)之映射类型
- JSONObject与JSONArray的使用
- php处理分布式事务的思考(转)
- 使用Node.js+Socket.IO搭建WebSocket实时应用
- poj 2236 Wireless Network
- 第七天Object类和异常
- Linux配置防火墙,开启80端口、3306端口 可能会遇到的小问题
- CSS中背景图片定位
- VC6.0 CXX0017:Error:symbol "xxx" not found问题解决方法
- ios基础入门——malloc方法
- java中的反射 2.3——类:发现类成员@译自Oracle官方文档
- 使用Node.js+Socket.IO搭建WebSocket实时应用(聊天室)
- java 获取工程部署的路径