博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【ZOJ】1610 Count the Colors
阅读量:4587 次
发布时间:2019-06-09

本文共 1218 字,大约阅读时间需要 4 分钟。

1 #include
2 #include
3 #define MAXN 8010 4 int tree[MAXN<<2],color[MAXN],ans[MAXN]; 5 inline void PushDown(int rt) 6 { 7 if(tree[rt]!=-1) 8 { 9 tree[rt<<1]=tree[rt<<1|1]=tree[rt];10 tree[rt]=-1;11 }12 }13 void Update(int x,int y,int val,int L,int R,int rt)14 {15 if(x<=L&&R<=y)16 tree[rt]=val;17 else18 {19 int mid=(L+R)>>1;20 PushDown(rt);21 if(mid>=x)22 Update(x,y,val,L,mid,rt<<1);23 if(y>mid)24 Update(x,y,val,mid+1,R,rt<<1|1);25 }26 }27 void Query(int L,int R,int rt)28 {29 if(tree[rt]!=-1)30 {31 for(int i=L;i<=R;i++)32 color[i]=tree[rt];33 }34 else if(L!=R)35 {36 int mid=(L+R)>>1;37 Query(L,mid,rt<<1);38 Query(mid+1,R,rt<<1|1);39 }40 }41 int main()42 {43 int n,x,y,val,i,j;44 while(~scanf("%d",&n))45 {46 memset(tree,-1,sizeof(tree));47 memset(color,-1,sizeof(color));48 memset(ans,0,sizeof(ans));49 while(n--)50 {51 scanf("%d%d%d",&x,&y,&val);52 if(x

转载于:https://www.cnblogs.com/DrunBee/archive/2012/05/22/2513498.html

你可能感兴趣的文章
mongodb入门
查看>>
猫眼电影top100抓取
查看>>
【codeforces】【比赛题解】#862 CF Round #435 (Div.2)
查看>>
SpringCloud学习笔记(8)----Spring Cloud Netflix之负载均衡-Ribbon的负载均衡的策略
查看>>
并发编程学习笔记(3)----synchronized关键字以及单例模式与线程安全问题
查看>>
2-9
查看>>
python多线程(一)
查看>>
MindManager中读图工具的使用
查看>>
利用GridView 插入、删除、修改、分页的综合实例代码---转!!!
查看>>
2016年3月11日Android学习日记
查看>>
Android弹出Toast工具类总结
查看>>
吴恩达机器学习笔记(十) —— 推荐系统
查看>>
Linux下Ant安装与配置
查看>>
实验二 用机器指令和汇编指令编程
查看>>
大数据系列之kafka监控kafkaoffsetmonitor安装
查看>>
常用正则表达式
查看>>
Java基础知识
查看>>
Identity Server4学习系列三
查看>>
我的一些学习资源
查看>>
第二届i春秋挖洞大赛的一些感想
查看>>