POJ2985 The k-th Largest Group(treap+并查集)

该博客介绍了如何利用Treap和并查集数据结构解决POJ2985问题,即在一系列合并操作后,查询第k大的猫组大小。博客提供了输入输出示例,并详细解释了题目的意思。通过将每次合并操作映射到Treap中删除元素,然后使用并查集合并组,最终将合并结果重新插入Treap,可以有效地找到所需的答案。
摘要由CSDN通过智能技术生成

题目链接


Input

1st line: Two numbers N and M (1 ≤ NM ≤ 200,000), namely the number of cats and the number of operations.

2nd to (m + 1)-th line: In each line, there is number C specifying the kind of operation Newman wants to do. If C = 0, then there are two numbers i and j (1 ≤ ij ≤ n) following indicating Newman wants to combine the group containing the two cats (in case these two cats are in the same group, just do nothing); If C = 1, then there is only one number k

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值