老司机树(Chtholly Tree (珂朵莉树) ODT)模板[codeforces 896C Willem, Chtholly and Seniorious]

本文介绍如何运用内置平衡树解决Codeforces竞赛中896C题目的区间合并问题。该问题的数据具有随机性和区间合并的特点,通过平衡树可以有效地处理这些信息。
摘要由CSDN通过智能技术生成

http://codeforces.com/contest/896/problem/C

由于题目数据随机生成,而且有合并区间的特性(据说合并后区间个数期望值跟logn有关)。

所以可以利用内置平衡树set合并区间信息并暴力。

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int mod7 = 1e9 + 7;
const int maxn = 1e5 + 7;

ll pow(ll a, ll b, ll mod){
    ll res=1;
    for(a%=mod;b;a=a*a%mod,b>>=1)
        if(b&1)res=res*a%mod;
    return res;
}
struct node{
    ll l,r;
    mutable ll v;
    node(ll l,ll r=-1,ll v=0):l(l),r(r),v(v){};
    bool operator<(const node& o) const {
        return l < o.l;
    }
};
set<node>ODT;

ll n,m,seed,vmax;

ll rnd(){
    ll ret=seed;
    seed=(seed*7+13)%mod7;
    return ret;
}
// 拆分操作
set<node>::iterator split(int pos){
    auto it=ODT.lower_bound(node(pos));
    if(it !=O
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值