当前位置:网站首页>[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;
}
边栏推荐
- Five constraints and three paradigms
- 力扣解法汇总919-完全二叉树插入器
- Solve several common problems
- 【集训DAY12】树!树!树!【贪心】【最小生成树】
- Method of converting MAPGIS format to ArcGIS
- 软件测试 pytest pytest的命名规则 用例的前后置 conftest.py 定制allure报告 @pytest.mark.parametrize()装饰器作数据驱动
- D3.js learning
- 数据质量:数据治理的核心
- Explore the use of self increasing and self decreasing operators
- Win10 set up a flutter environment to step on the pit diary
猜你喜欢

【集训DAY15】油漆道路【最小生成树】

Square root of X

Pyspark data analysis basis: pyspark.sql.sparksession class method explanation and operation + code display

xss-工具-Beef-Xss安装以及使用
![[PMP learning notes] Chapter 1 Introduction to PMP System](/img/80/144124af40f0a015c4deafc3aa7432.png)
[PMP learning notes] Chapter 1 Introduction to PMP System

ML-Numpy

Data governance under data platform

【集训DAY12】树!树!树!【贪心】【最小生成树】

Xiaobai programmer's sixth day

About vscode usage+ Solutions to the problem of tab failure
随机推荐
arcgis开发常用源码
【集训DAY12】树!树!树!【贪心】【最小生成树】
【集训DAY15】好名字【hash】
点亮字符串中所有需要点亮的位置,至少需要点几盏灯
XSS tool beef XSS installation and use
Wechat applet application development competition works comprehensive development record - Jinlu cultural tourism (cloud development - Overview)
Common source code for ArcGIS development
The price of dividing gold bars
The third day of Xiaobai programmer
Tfrecord write and read
VIM usage record
对需求的内容进行jieba分词并按词频排序输出excel文档
【集训DAY13】Internet【并查集】
数学规划分类 Math Programming Classfication
Five constraints and three paradigms
Google analyzes how UA can be transferred to the latest version of GA4
启牛商学院和微淼商学院哪个靠谱?老师推荐的开户安全吗?
ArcGIS中的WKID
Arcgis10.2 configuring postgresql9.2 standard tutorial
Simulated Xiaomi mall head home page