LG1840 Color the Axis 线段树
菜的人就要写简单题
为了练习手速来写这样一道 珂朵莉树 线段树简单题
没啥可说的,注意修改操作中要判一下 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 线段树的更多相关文章
- HDU.1556 Color the ball (线段树 区间更新 单点查询)
HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #includ ...
- HDU 1556 Color the ball(线段树区间更新)
Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...
- hdu 6183 Color it (线段树 动态开点)
Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B ...
- hdu 1556 Color the ball (线段树+代码详解)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 2018.07.08 hdu6183 Color it(线段树)
Color it Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) Proble ...
- hdu 1556 Color the ball(线段树区间维护+单点求值)
传送门:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/3276 ...
- HDU - 6183:Color it (线段树&动态开点||CDQ分治)
Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B ...
- Count Color POJ - 2777 线段树
Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds ...
- ZOJ 2301 Color the Ball 线段树(区间更新+离散化)
Color the Ball Time Limit: 2 Seconds Memory Limit: 65536 KB There are infinite balls in a line ...
随机推荐
- 一个随机切换user_agent的第三方python库:my_fake_useragent
因为my_fake_useragent 是第三方,所以需要自己进行安装. 不用担心,它没有任何依赖或者附加环境,只安装它自己就行. 方法1: pycharm传统安装方式. 方法2: pip insta ...
- django-channels的部署(supervisor+daphne+nginx)
项目中需要一个聊天室的功能,所以需要websocket通信,选择了使用channels模块,主要记录下channels部署的配置和一些坑. 原项目是通过nginx+uwsgi部署的,这里我没做任何改动 ...
- 松软科技web课堂:随机Math.random()
Math.random() 返回 0(包括) 至 1(不包括) 之间的随机数: 实例 Math.random(); // 返回随机数 JavaScript 随机整数 Math.random() 与 M ...
- ESPCMS P8 stable version Front-end reflective xss
Download the source code first In the directory espcms_web\espcms_load.php line 67 if (!is_file($mod ...
- Python读字节某一位的值,设置某一位的值,二进制位操作
Python读字节某一位的值,设置某一位的值,二进制位操作 在物联网实际应用项目开发中,为了提升性能,与设备端配合,往往最终使用的是二进制字节串方式进行的通信协议封装,更会把0和1.True和Fa ...
- facl 用户以及Linux 终端
FACL : Filesystem Access Control List 利用文件扩展保存额外的访问控制权限setfacl -b:Remove all -m:设定 u:UID:perm g:GID: ...
- 011.Kubernetes二进制部署kube-scheduler
一 部署高可用kube-scheduler 1.1 高可用kube-scheduler介绍 本实验部署一个三实例 kube-scheduler 的集群,启动后将通过竞争选举机制产生一个 leader ...
- Map随笔:最常用的Map——HashMap
目录 Map随笔:最常用的Map--HashMap 前言: 1,HashMap的结构 2,HashMap的一些属性(JDK8) 3,HashMap的构造函数(JDK8) 4,HashMap的一些方法( ...
- day97_11_29
一.数据存储到mongodb 爬取的数据如果需要存储到mongodb中,要通过item,定义一个存储类.再yield一个类. 数据存储的时候需要进过pipelines,再到setting中配置. fr ...
- swoole视频直播
$serv=new swoole_websocket_server("0.0.0.0",9501);$client=array();$serv->on("open& ...