当前位置:网站首页>[training day13] Internet [concurrent search]
[training day13] Internet [concurrent search]
2022-07-25 22:30:00 【VL——MOESR】

Ideas :
We found that after each repair, we only need a joint search set to connect the connected ones .
c o d e code code
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
const int MAXN = 1010;
int n, d, fa[MAXN];
struct node {
int x, y;
}a[MAXN];
bool v[MAXN];
double dis(int x, int y) {
return sqrt((a[x].x - a[y].x) * (a[x].x - a[y].x) * 1.0 + (a[x].y - a[y].y) * (a[x].y - a[y].y) * 1.0);
}
int getfa(int x) {
if(x == fa[x]) return x;
return fa[x] = getfa(fa[x]);
}
int main() {
scanf("%d%d", &n, &d);
for(int i = 1; i <= n; i ++) scanf("%d%d", &a[i].x, &a[i].y), fa[i] = i;
char ch;
int x, y;
scanf("%c", &ch);
while(scanf("%c", &ch) != EOF) {
if(ch == 'O') {
scanf("%d", &x);
v[x] = 1;
for(int i = 1; i <= n; i ++) {
if(v[i] && dis(x, i) <= d * 1.0) {
int xx = getfa(x), yy = getfa(i);
if(xx == yy) continue;
fa[xx] = yy;
}
}
}
else {
scanf("%d%d", &x, &y);
if(!v[x] || !v[y]) {
printf("FAIL\n");
scanf("%c", &ch);
continue;
}
int xx = getfa(x), yy = getfa(y);
if(xx == yy) printf("SUCCESS\n");
else printf("FAIL\n");
}
scanf("%c", &ch);
}
return 0;
}
边栏推荐
- Data governance under data platform
- 【集训DAY13】Backpack【动态规划】【贪心】
- IFLYTEK smart office book air e-book reader makes my work life healthier
- win10搭建flutter环境踩坑日记
- H5幸运刮刮乐抽奖 免公众号+直运营
- [C syntax] void*
- Xiaobai programmer's first day
- (1) DDL, DML, DQL, DCL and common data types
- Internship: writing common tool classes
- 微信发卡小程序源码-自动发卡小程序源码-带流量主功能
猜你喜欢

Title: give a group of arrays, arranged from large to small and from small to large.

Using simple scripts to process data in 3dslicer

ThreadLocal summary (to be continued)

Tfrecord write and read

Xiaobai programmer's fourth day

ML-Numpy

完啦,上班三个月,变秃了

Xiaobai programmer's first day

对需求的内容进行jieba分词并按词频排序输出excel文档

win10搭建flutter环境踩坑日记
随机推荐
力扣解法汇总919-完全二叉树插入器
3 词法分析
Pyspark data analysis basis: pyspark.sql.sparksession class method explanation and operation + code display
Wechat applet (anti shake, throttling), which solves the problem that users keep pulling down refresh requests or clicking buttons to submit information; Get the list information and refresh the data
Xiaobai programmer's fourth day
沃达德软件:智慧城市方案
Wechat card issuing applet source code - automatic card issuing applet source code - with flow main function
How to call the size of two numbers with a function--- Xiao Tang
H5幸运刮刮乐抽奖 免公众号+直运营
Google analyzes how UA can be transferred to the latest version of GA4
分割金条的代价
XSS tool beef XSS installation and use
The third day of Xiaobai programmer
ArcGIS中的WKID
力矩电机控制基本原理
To light up all the positions in the string that need to be lit, at least a few lights are needed
Xiaobai programmer's seventh day
数学规划分类 Math Programming Classfication
Which is reliable between qiniu business school and WeiMiao business school? Is it safe to open an account recommended by the teacher?
win10搭建flutter环境踩坑日记