>Link
luogu CF896C
>Description
>解题思路
珂朵莉树,一种奇妙的数据结构使得暴力跑的飞快
这种数据结构的重要就是“推平”,题目中的第二种操作。
珂朵莉树把每段连续的且数值相同的区间存为一体,放入set(按照位置从小到大排序)。如果操作一个区间 [ l , r ] [l,r] [l,r],就把 l , r l,r l,r 各自存在的区间分裂 s p l i t split split成两个区间,再进行操作。
其他就是直接暴力
>代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <utility>
#define LL long long
#define N 100010
#define sett set<node>::iterator
using namespace std;
using std::set;
using std::vector;
struct node
{
int l, r;
mutable LL v;
node (int L, int R = -1, LL V = 0) : l (L), r (R), v (V) {
}
bool operator < (const node &aa) const
{
return l < aa.l;
}
};
struct rk
{
int tot; LL