菜的人就要写简单题

为了练习手速来写这样一道 珂朵莉树 线段树简单题

没啥可说的,注意修改操作中要判一下 val=0

#include<bits/stdc++.h>
using namespace std; const int maxn=200007; int val[maxn*4],lazy[maxn*4]; #define lfc (x<<1)
#define rgc ((x<<1)|1)
#define mid ((l+r)>>1) int n,T; void pushup(int x){
val[x]=val[lfc]+val[rgc];
} void build(int x,int l,int r){
if(l==r){
val[x]=1;return;
}
build(lfc,l,mid);build(rgc,mid+1,r);
pushup(x);
} int L,R; void change(int x,int l,int r){
if(r<L||R<l) return;
if(L<=l&&r<=R){
val[x]=0;return;
}
if(!val[x]) return;
change(lfc,l,mid);change(rgc,mid+1,r);
pushup(x);
} int query(void){
return val[1];
} int main(){
scanf("%d%d",&n,&T);
build(1,1,n);
while(T--){
int l,r;
scanf("%d%d",&l,&r);
L=l,R=r;change(1,1,n);
printf("%d\n",query());
}
return 0;
}

LG1840 Color the Axis 线段树的更多相关文章

  1. HDU.1556 Color the ball (线段树 区间更新 单点查询)

    HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #includ ...

  2. HDU 1556 Color the ball(线段树区间更新)

    Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...

  3. hdu 6183 Color it (线段树 动态开点)

    Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B ...

  4. hdu 1556 Color the ball (线段树+代码详解)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  5. 2018.07.08 hdu6183 Color it(线段树)

    Color it Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) Proble ...

  6. hdu 1556 Color the ball(线段树区间维护+单点求值)

    传送门:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/3276 ...

  7. HDU - 6183:Color it (线段树&动态开点||CDQ分治)

    Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B ...

  8. Count Color POJ - 2777 线段树

    Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds ...

  9. ZOJ 2301 Color the Ball 线段树(区间更新+离散化)

    Color the Ball Time Limit: 2 Seconds      Memory Limit: 65536 KB There are infinite balls in a line ...

随机推荐

  1. vue-cli3.0配置图片转base64的规则

    vue-cli3.0发现打包的时候,一些小于10k的图片没有转base64,需要自己新建一个vue.config.js的文件(在根目录),然后进行如下配置,就可以控制图片转义规则 module.exp ...

  2. [css flex布局]实例一,本来还想挺简单的,弄了挺久呢,先写一部分

    全是代码,直接拷走吧,看是不怎么好看的 参考:http://www.ruanyifeng.com/blog/search.html?cx=016304377626642577906%3Ab_e9ska ...

  3. Tesseract.js 一个几乎能识别出图片中所有语言的JS库

    Tesseract.js 一个几乎能识别出图片中所有语言的JS库. 官网:http://tesseract.projectnaptha.com/ git:https://github.com/napt ...

  4. Github访问速度很慢的原因,以及解决方法

    1,CDN,Content Distribute Network,可以直译成内容分发网络,CDN解决的是如何将数据快速可靠从源站传递到用户的问题.用户获取数据时,不需要直接从源站获取,通过CDN对于数 ...

  5. Error: Unable to establish IPMI v2 / RMCP+ session

    是这样的,需要ipmi控制器,然后一直报错这个: [root@localhost ~]# sudo ipmitool -I lanplus -H 192.168.87.12 -U root -P pa ...

  6. Nginx:反向代理

    与众不同的生活方式很累人呢,因为找不到借口     在上一章节中,我们以及了解到正向.反向代理.负载均衡和动静分离的基本概念,安装教程,而在本节中将会了解到在 本文要点: 1.理清概念 2.Linux ...

  7. PC上装VM上装虚拟机

    1.虚拟机网卡选择桥接模式 2.查看本PC机的网络 3.到/etc/sysconfig/network-scripts,修改网卡,vi ifcfg-ens33 4.重新/etc/init.d/netw ...

  8. error: [debug/qrc_resource.cpp] Error 1

    t在进行debug时,出现这个错误,去资源文件夹,用资源编辑器打开resource.qrc文件,查看是否有标红的资源文件. 如果有红色名称的资源文件,那么就是因为缺少该资源文件,导致的这个错误. 改正 ...

  9. npm报错及解决

    nodejs安装之后 无法使用 npm的解决方法 首先我们要知道Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境 Node.js 使用了一个事件驱动.非阻塞式 I ...

  10. mysql给字段取别名无法被jdbc解析的解决办法

    项目上用的Spring JDBC,是通过ResultSetMetaData接口来调用具体数据库的JDBC实现类来获取数据库返回结果集的. 在项目开发中,发现在MySQL中使用的别名没有办法被正常解析, ...