并查集
文章平均质量分 70
___fouzhe
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
使用并查集判断无向图是否连通
以下代码是使用并查集判断无向图是否连通#include<bits/stdc++.h> //无向图使用并查集判断是否连通 using namespace std;const int maxn=1e5+10;int par[maxn];void init(int n){ for(int i=0;i<n;i++) par[i]=i;}i原创 2016-05-13 22:27:48 · 2856 阅读 · 0 评论 -
Codeforces Round #363 (Div. 2)D. Fix a Tree并查集
题目链接题目描述 D. Fix a Tree time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A tree is an undirected connected graph without cycles.Let’s consi原创 2016-07-22 23:08:46 · 438 阅读 · 0 评论 -
uva10129(play with words)
题目描述: Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is ve原创 2016-07-12 23:19:08 · 790 阅读 · 1 评论 -
并查集(路径压缩)
并查集路径压缩递归写法:int find(int x){ return pa[x]==x? x:find(pa[x]);}有时候数据太大会因为递归层数太多而RE,那么此时可以选择以下非递归版本。并查集路径压缩非递归写法:int find(int x){ if(pa[x]==x) return x; int r=x; while(pa[x]!=r)原创 2016-07-15 11:27:37 · 603 阅读 · 0 评论 -
Codeforces Round 722C:Destroying Array(并查集,好题)
题目链接C. Destroying Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array consistin原创 2016-10-02 10:46:32 · 3591 阅读 · 0 评论 -
POJ 1988 Cube Stacking(带权并查集)
题目链接Cube StackingTime Limit: 2000MS Memory Limit: 30000KTotal Submissions: 24006 Accepted: 8431Case Time Limit: 1000MSDescriptionFarmer John and Bet原创 2016-10-03 13:17:13 · 500 阅读 · 0 评论 -
poj 1733 Parity game(带权并查集)
题目链接Parity gameTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8154 Accepted: 3179DescriptionNow and then you play the following game with your原创 2016-10-04 12:08:27 · 985 阅读 · 0 评论 -
51nod 1821 最优集合(想法+贪心+并查集)
1821 最优集合基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注一个集合S的优美值定义为:最大的x,满足对于任意i∈[1,x],都存在一个S的子集S',使得S'中元素之和为i。给定n个集合,对于每一次询问,指定一个集合S1和一个集合S2,以及一个数k,要求选择一个S2的子集S3(|S3|原创 2017-03-16 00:17:13 · 860 阅读 · 0 评论
分享