中文题面

据说正解是动态开点线段树而且标记也不难下传的样子

然而这种区间推平的题目还是喜欢写珂朵莉树啊……码量小……

虽然真要构造的话随便卡……

 //minamoto
#include<cstdio>
#include<set>
#include<iostream>
#define IT set<node>::iterator
using namespace std;
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[<<],*p1=buf,*p2=buf;
inline int read(){
#define num ch-'0'
char ch;bool flag=;int res;
while(!isdigit(ch=getc()))
(ch=='-')&&(flag=true);
for(res=num;isdigit(ch=getc());res=res*+num);
(flag)&&(res=-res);
#undef num
return res;
}
char sr[<<],z[];int K=-,Z;
inline void Ot(){fwrite(sr,,K+,stdout),K=-;}
inline void print(int x){
if(K><<)Ot();if(x<)sr[++K]=,x=-x;
while(z[++Z]=x%+,x/=);
while(sr[++K]=z[Z],--Z);sr[++K]='\n';
}
struct node{
int l,r;mutable int v;
node(int L,int R=-,int V=):l(L),r(R),v(V){}
inline bool operator <(const node &b)const
{return l<b.l;}
};
set<node> s;int sum;
IT split(int pos){
IT it=s.lower_bound(node(pos));
if(it!=s.end()&&it->l==pos) return it;
--it;
int l=it->l,r=it->r,v=it->v;
s.erase(it);
s.insert(node(l,pos-,v?pos-l:));
return s.insert(node(pos,r,v?r-pos+:)).first;
}
void assign(int l,int r,int v){
IT itr=split(r+),itl=split(l);
for(IT it=itl;it!=itr;++it) sum-=it->v;
s.erase(itl,itr),s.insert(node(l,r,v*(r-l+)));
sum+=v*(r-l+);
}
int main(){
// freopen("testdata.in","r",stdin);
int n=read(),q=read();
s.insert(node(,n+,));sum=n;
while(q--){
int l=read(),r=read();
assign(l,r,read()-);
print(sum);
}
return Ot(),;
}

CF915E Physical Education Lessons(珂朵莉树)的更多相关文章

  1. CF915E Physical Education Lessons 珂朵莉树

    问题描述 CF915E LG-CF915E 题解 \(n \le 10^9\) 看上去非常唬人. 但是这种区间操作的题,珂朵莉树随便跑啊. \(\mathrm{Code}\) #include< ...

  2. CF915E Physical Education Lessons 动态开点线段树

    题目链接 CF915E Physical Education Lessons 题解 动态开点线段树 代码 /* 动态开点线段树 */ #include<cstdio> #include&l ...

  3. 【题解】Luogu CF915E Physical Education Lessons

    原题传送门:CF915E Physical Education Lessons 前置芝士:珂朵莉树 窝博客里对珂朵莉树的介绍 没什么好说的自己看看吧 这道题很简单啊 每个操作就是区间赋值,顺带把总和修 ...

  4. [转]我的数据结构不可能这么可爱!——珂朵莉树(ODT)详解

    参考资料: Chtholly Tree (珂朵莉树) (应某毒瘤要求,删除链接,需要者自行去Bilibili搜索) 毒瘤数据结构之珂朵莉树 在全是珂学家的珂谷,你却不知道珂朵莉树?来跟诗乃一起学习珂朵 ...

  5. 洛谷AT2342 Train Service Planning(思维,动态规划,珂朵莉树)

    洛谷题目传送门 神仙思维题还是要写点东西才好. 建立数学模型 这种很抽象的东西没有式子描述一下显然是下不了手的. 因为任何位置都以\(k\)为周期,所以我们只用关心一个周期,也就是以下数都在膜\(k\ ...

  6. 洛谷P4344 [SHOI2015]脑洞治疗仪(珂朵莉树)

    传送门 看到区间推倒……推平就想到珂朵莉树 挖脑洞直接assign,填坑先数一遍再assign再暴力填,数数的话暴力数 //minamoto #include<iostream> #inc ...

  7. 洛谷P2787 语文1(chin1)- 理理思维(珂朵莉树)

    传送门 一看到区间推倒……推平操作就想到珂朵莉树 区间推平直接assign,查询暴力,排序的话开一个桶统计,然后一个字母一个字母加就好了 开桶统计的时候忘了保存原来的左指针然后挂了233 //mina ...

  8. 洛谷P2082 区间覆盖(加强版)(珂朵莉树)

    传送门 虽然是黄题而且还是一波离散就能解决的东西 然而珂朵莉树还是很好用 相当于一开始区间全为0,然后每一次区间赋值,问最后总权值 珂朵莉树搞一搞就好了 //minamoto #include< ...

  9. 洛谷P2572 [SCOI2010]序列操作(珂朵莉树)

    传送门 珂朵莉树是个吼东西啊 这题线段树代码4k起步……珂朵莉树只要2k…… 虽然因为这题数据不随机所以珂朵莉树的复杂度实际上是错的…… 然而能过就行对不对…… (不过要是到时候noip我还真不敢打… ...

随机推荐

  1. python学习之 - 时间模块

    时间模块模块名:time时间模块的转换流程图. UTC:英国格林威治时间.时间戳作用:是用来进行时间计算的.进行加减时间.注意:时间计算是用秒为单位time.process_time():测量处理器运 ...

  2. Generate Parentheses(组合,回溯)

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  3. Oracle冷备和热备脚本

    Oracle冷备和热备脚本 冷备脚本: set feedback off set heading off set verify  off set trimspool off set echo off ...

  4. 【Mongodb教程 第三课 】MongoDB 删除数据库

    dropDatabase() 方法 MongoDB db.dropDatabase() 命令是用来删除一个现有的数据库. 语法: dropDatabase() 命令的基本语法如下: db.dropDa ...

  5. 【转】LoadRunner监控 -- Linux的17个指标

    这17个指标根据需要设置,指标设置的越多,对服务器真实值影响越大,所以要秉承按需而设的原则.   1.Average load:Average number of processes simultan ...

  6. 2.NetDh框架之简单高效的日志操作类(附源码和示例代码)

    前言 NetDh框架适用于C/S.B/S的服务端框架,可用于项目开发和学习.目前包含以下四个模块 1.数据库操作层封装Dapper,支持多种数据库类型.多库实例,简单强大: 此部分具体说明可参考博客: ...

  7. Redhat enterpise6 安装unix2dos/dos2unix

    初用unix2dos,在rhel6 上 用yum install unix2dos , 提示源不可用, 那好吧, 就去rpm包网:http://rpm.pbone.net/ 下载了一个unix2dos ...

  8. nginx与apache 对比 apache是同步多进程模型,一个连接对应一个进程;nginx是异步的,多个连接(万级别)可以对应一个进程

    nginx与apache详细性能对比 http://m.blog.csdn.net/lengzijian/article/details/7699444 http://www.cnblogs.com/ ...

  9. sqlyog快捷键

    Ctrl+M   创建一个新的连接Ctrl+N   使用当前设置新建连接Ctrl+F4   断开当前连接 对象浏览器F5   刷新对象浏览器(默认)Ctrl+B   设置焦点于对象浏览器 SQL 窗口 ...

  10. Delphi XE10调用WebService服务获取图片验证码

    最近做了一个程序,需要使用图片验证码,百度一下,网上一大把免费的WebService服务,随意找一个用用,效果还可以.WebService地址:http://www.webxml.com.cn/Web ...