并查集
文章平均质量分 75
bingbingsyr
这个作者很懒,什么都没留下…
展开
-
Is It A Tree?
题意:与小希的迷宫相似,也是不能成环 Description A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfy原创 2015-03-12 20:18:04 · 337 阅读 · 0 评论 -
经典并查集之畅通工程
这道题也是非常经典的并查集,类似于n个点,(n-1)条边的问题,以下是代码 #include using namespace std; int pre[20010]; void init (int n) { int i; for(i=0;i<=n;i++) pre[i]=i; } int find(int x) { int root=x; while(原创 2015-03-12 20:07:29 · 394 阅读 · 0 评论 -
经典的并查集之How Many Tables
Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends kno原创 2015-03-12 20:00:10 · 357 阅读 · 0 评论 -
小希的迷宫
Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她原创 2015-03-12 20:12:30 · 332 阅读 · 0 评论 -
离线+并查集 Portal
做这题学到了什么是“离线算法”的概念。所谓“离线”,就是把所有的数据都输入之后再计算,“在线”就是边输入边计算。 用在这题中,是因为输入中的“询问部分”,有Q 个问,每个L可以有多少种不同路径。由于大的L必定会包含到小的L, 所以把所有问题都输入,再从大到小排序,再计算,可以减少很多计算量。 Description ZLGG found a magic theory转载 2015-03-12 20:54:38 · 637 阅读 · 0 评论 -
More is better
这道题也非常的经典,大意就是,是朋友的都分在一起(朋友的朋友也是朋友);会有很多的团体,输出人数最多的团体的人数; Description Mr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the bette原创 2015-03-12 20:28:33 · 387 阅读 · 0 评论