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