CF896C Willem, Chtholly and Seniorious【珂朵莉树】

>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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值