并查集
whiskey_wei
这个作者很懒,什么都没留下…
展开
-
并查集
原文:http://www.cnblogs.com/TonyNeal/p/bingchaji.html 来看一个实例:http://acm.hdu.edu.cn/showproblem.php?pid=1232 首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整转载 2017-04-12 15:55:08 · 322 阅读 · 0 评论 -
并查集_hdu1213
How Many Tables http://acm.hdu.edu.cn/showproblem.php?pid=1213 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how man原创 2017-04-12 18:59:47 · 3009 阅读 · 1 评论 -
hdu1232通畅工程
水题,并查集,dfs都可以做出来 #include using namespace std; int f[1005]; int findd(int x) { while(x!=f[x]) x=f[x]; return x; } void join(int x,int y) { int fx=findd(x); int fy=findd(y);原创 2017-05-15 16:58:43 · 225 阅读 · 0 评论 -
小希的迷宫
看到这个题一开始想到并查集,仔细想了下,其实可以直接统计点数和边数,再作比较,就直接出来了 #include #include #include using namespace std; int main() { bool vis[100005]; int a,b; int cnt1=0,cnt2=0; memset(vis,0,sizeof(vi原创 2017-07-20 13:02:47 · 167 阅读 · 0 评论