并查集
Eloi0424
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
P2814 家谱(字符串并查集)
个人博客:Eloi-还在前进.P2814 家谱(字符串并查集)题目来源:洛谷P2814 家谱题目描述:给出充足的父子关系,请你编写程序找到某个人的最早的祖先。解题思路:本题其实就是一个普通并查集+map构建的哈希表。map构建的哈希表具有下标任意,储存数据任意的特点。故正好解决了字符串之间连边问题。AC代码:#include <bits/stdc++.h>using namespace std;map <string,string> father;strin原创 2021-08-20 13:06:26 · 259 阅读 · 0 评论 -
P1111 修复公路(并查集)
#include <bits/stdc++.h>using namespace std;int father[1005];struct road{ int x; int y; int t;}r[100005];int cmp(road x,road y){ return x.t<y.t;}int find(int x){ if(father[x]==x) return x; else return find(father[原创 2021-08-17 16:17:01 · 817 阅读 · 0 评论
分享