菜的人就要写简单题

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

没啥可说的,注意修改操作中要判一下 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. c# 保留2位小数 整数时无小数

    对数值保存两位小数,有时是整数时,不需要显示两位小数.例如值为:1.32 保留两位,结果是1.32,值为:2,结果有两种显示,2和2.00 /// <summary> /// 金额 /// ...

  2. JS---DOM---节点的概念,属性,和获取相关的节点

    回顾概念 文档: document 元素: 页面中所有的标签, 元素---element,  标签----元素---对象 节点: 页面中所有的内容(标签,属性,文本(文字,换行,空格,回车))---- ...

  3. OSG嵌入QT的简明总结

    目录 1.解决方案 2.存在问题 1) 警告提示 2) 多线程问题 3) 其他 1.解决方案 不得不说关于OSG的资料实在太零散了,搜索了很多关于OSG在QT下的解决方案,都是各有各的说法,有的说的不 ...

  4. JDK环境变量配置遇见的错误以及解决办法

    cmd中输入java -version错误信息: An error has occurred while processing the shared archive file.Unable to un ...

  5. C#数据采集用到的几个方法

    这两天在做数据采集,因此整理了下数据采集要用到的一些方法.因为我采集的数据比较简单,所以没有用到框架.比较有名的两个框架 HtmlAgilityPack 和 Jumony,感兴趣的可以研究下.当然,火 ...

  6. SQL Server如何正确的删除Windows认证用户

    在SQL Server数据库中,有时候会建立一些Windows认证的账号(域账号),例如,我们公司习惯给开发人员和Support同事开通NT账号权限,如果有离职或负责事宜变更的话,那么要如何正确的删除 ...

  7. 阿里云ECS服务器部署HADOOP集群(六):Flume 安装

    本篇将在阿里云ECS服务器部署HADOOP集群(一):Hadoop完全分布式集群环境搭建的基础上搭建. 1 环境介绍 一台阿里云ECS服务器:master 操作系统:CentOS 7.3 Hadoop ...

  8. IDEA 工具自动生成JavaBean类

    1.先安装GsonFormat插件:File-->Setting-->Plugins-->GsonFormat-->OK 2.new 一个新的Class空文件,然后 Alt+I ...

  9. Python文件操作:文件的打开关闭读取写入

    Python文件操作:文件的打开关闭读取写入 一.文件的打开关闭 Python能以文本和二进制两种方式处理文件,本文主要讨论在Python3中文本文件的操作. 文件操作都分为以下几个步骤: 1.打开文 ...

  10. Office批量打印助手(Excel 批量打印、Word 批量打印)

    最新版本:1.0.6664.34636(更新日期:2018年3月31日) 下载地址:点击下载  程序简介: 本程序能批量打印 Word 文件.Excel 工作簿. 使用程序前请先安装 .NET Fra ...