#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define N 1000005
using namespace std; int c[];
int tree[N*];//正值表示该节点所管理的区间的颜色是纯色,-1表示的是非纯色
int n, m; void buildT(int ld, int rd, int p){
if(ld <= rd){
tree[p] = ;//初始每一个节点的颜色全部都是2
if(ld == rd) return;
int mid=(ld + rd)>>;
buildT(ld, mid, p<<);
buildT(mid+, rd, p<<|);
}
} void updateT(int ld, int rd, int a, int b, int col, int p){ if(ld > rd) return ; if(tree[p] == col) return ; if(ld == a && rd == b){
tree[p] = col;
return ;
}
int mid = (ld + rd)>>; if(tree[p] != -){// p所管的区间之前是纯色,现在不是纯色了,向下更新其孩子节点的颜色为它的颜色
tree[p<<] = tree[p<< | ] = tree[p];
tree[p] = -;
} if(a > mid)
updateT(mid+, rd, a, b, col, p<< | );
else if(b <= mid)
updateT(ld, mid, a, b, col, p<<);
else{
updateT(ld, mid, a, mid, col, p<<);
updateT(mid+, rd, mid+, b, col, p<< | );
}
} int cnt; void querryT(int ld, int rd, int a, int b, int p){
if(ld>rd) return ; if(tree[p] != -){//一直找到纯色的区间!
c[tree[p]]=;
return ;
} int mid = (ld+rd)>>;
if(a > mid)
querryT(mid+, rd, a, b, p<< | );
else if(b <= mid)
querryT(ld, mid, a, b, p<<) ;
else{
querryT(ld, mid, a, mid, p<<);
querryT(mid+, rd, mid+, b, p<< | );
}
} int main(){
while(scanf("%d%d", &n, &m) && (n || m)){
char ch[];
int a, b, k;
buildT(, n, );
while(m--){
scanf("%s", ch);
if(ch[] == 'P'){
scanf("%d%d%d", &a, &b, &k);
updateT(, n, a, b, k, );
}
else{
scanf("%d%d", &a, &b);
memset(c, , sizeof(c));
querryT(, n, a, b, );
int i;
for(i=; i<=; ++i)
if(c[i]){
printf("%d", i);
break;
}
for(++i; i<=; ++i)
if(c[i]) printf(" %d", i);
printf("\n");
}
}
}
return ;
}

2014 网选 广州赛区 hdu 5023 A Corrupt Mayor's Performance Art的更多相关文章

  1. hdu 5023 A Corrupt Mayor's Performance Art 线段树

    A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100 ...

  2. 2014 网选 广州赛区 hdu 5025 Saving Tang Monk(bfs+四维数组记录状态)

    /* 这是我做过的一道新类型的搜索题!从来没想过用四维数组记录状态! 以前做过的都是用二维的!自己的四维还是太狭隘了..... 题意:悟空救师傅 ! 在救师父之前要先把所有的钥匙找到! 每种钥匙有 k ...

  3. ACM学习历程—HDU 5023 A Corrupt Mayor's Performance Art(广州赛区网赛)(线段树)

    Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sel ...

  4. HDU 5023 A Corrupt Mayor's Performance Art 线段树区间更新+状态压缩

    Link:  http://acm.hdu.edu.cn/showproblem.php?pid=5023 #include <cstdio> #include <cstring&g ...

  5. HDU 5023 A Corrupt Mayor's Performance Art(线段树区间更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5023 解题报告:一面墙长度为n,有N个单元,每个单元编号从1到n,墙的初始的颜色是2,一共有30种颜色 ...

  6. HDU 5023 A Corrupt Mayor's Performance Art (据说是线段树)

    题意:给定一个1-n的墙,然后有两种操作,一种是P l ,r, a 把l-r的墙都染成a这种颜色,另一种是 Q l, r 表示,输出 l-r 区间内的颜色. 析:应该是一个线段树+状态压缩,但是我用s ...

  7. hdu - 5023 - A Corrupt Mayor's Performance Art(线段树)

    题目原文废话太多太多太多,我就不copyandpaste到这里啦..发个链接吧题目 题目意思就是:P  l  r  c  将区间 [l ,r]上的颜色变成c    Q  l r 就是打印出区间[l,r ...

  8. 2014 网选 上海赛区 hdu 5047 Sawtooth

    题意:求n个'M'型的折线将一个平面分成的最多的面数! 思路:我们都知道n条直线将一个平面分成的最多平面数是 An = An-1 + n+1 也就是f(n) = (n*n + n +2)/2 对于一个 ...

  9. 2014 网选 5024 Wang Xifeng's Little Plot

    题意:从任意一个任意一个可走的点开始找一个最长的路,这条路如果有转弯的话, 那么必须是 90度,或者没有转弯! 思路: 首先用dfs将所有可走点开始的 8 个方向上的线段的最长长度求出来 ! step ...

随机推荐

  1. Anywhere服务建立及连接步骤

    <烟叶自动化收购管理系统(山东版)>服务端程序为<烟站综合管理系统5.0>,5.0使用的数据库为Anywhere,设置方法如下:   建立anywhere服务连接步骤   服务 ...

  2. WORD2003电子签名插件(支持手写、签章)

    1.引言 WORD电子签名插件,支持手写.本地电子图章.以及网络图章功能.软件使用VC6,以ATL方式编写,软件小巧精致. 这是我学习ATL的成果,学习过程及程序的编写,前前后后共用了一个多月的时间, ...

  3. UIScrollView offset in UINavigationController

    转:UIScrollView offset in UINavigationController 通过设置viewCtronller的 self.automaticallyAdjustsScrollVi ...

  4. 通过boundingRectWithSize:options:attributes:context:计算文本尺寸

    转:http://blog.csdn.net/iunion/article/details/12185077   之前用Text Kit写Reader的时候,在分页时要计算一段文本的尺寸大小,之前使用 ...

  5. Entity Framework6 with Oracle

    Entity Framework6 with Oracle(可实现code first) Oracle 与2个月前刚提供对EF6的支持.以前只支持到EF5.EF6有很多有用的功能 值得升级.这里介绍下 ...

  6. ORACLE 监听日志文件太大停止写监听日志引起数据库连接不上问题

    生产库监听日志文件太大(达到4G多),发现oracle停止写监听日志,检查参数log_file,log_directory,log_status 均正常,数据库运行也正常. 经确认确实为监听日志过大引 ...

  7. pip 豆瓣镜像使用

    pip install -i https://pypi.douban.com/simple/ flask 要用https的 https://pip.pypa.io/en/latest/user_gui ...

  8. 【CUDA学习】GPU硬件结构

    GPU的硬件结构,也不是具体的硬件结构,就是与CUDA相关的几个概念:thread,block,grid,warp,sp,sm. sp: 最基本的处理单元,streaming processor  最 ...

  9. SQL Server 2008 Datetime Cast 成 Date 类型可以使用索引(转载)

    很久没写blog,不是懒,实在是最近我这的访问速度不好,用firefox经常上传不了图片 ....... 今天无意发现了SQL Server 2008 Datetime Cast 成 Date 类型可 ...

  10. exam help

    http://forceprepare.com/ http://forcecertified.com/certifications/certified-developer/ http://blog.l ...