//Accepted    4768 KB    391 ms
 //线段树,延时标记的应用
 //对于每一段,用一个int表示被着色的情况,change标记该段的颜色是否发生整体的改变,即这一段
 //用没用被全部涂成令一种颜色
 #include <cstdio>
 #include <cstring>
 #include <iostream>
 #include <queue>
 #include <cmath>
 #include <algorithm>
 using namespace std;
 /**
   * This is a documentation comment block
   * 如果有一天你坚持不下去了,就想想你为什么走到这儿!
   * @authr songt
   */
 ;
 struct node
 {
     int l,r;
     int color;
     bool change;
 }f[imax_n*];
 void build(int t,int l,int r)
 {
     f[t].l=l;
     f[t].r=r;
     f[t].change=;
     f[t].color=<<;
     if (l==r)
     {
         return ;
     }
     ;
     build(*t,l,mid);
     build(*t+,mid+,r);
 }
 int query(int t,int l,int r)
 {
     if (f[t].l==l && f[t].r==r)
     {
         return f[t].color;
     }
     )
     {
         f[*t].color=f[t].color;
         f[*t+].color=f[t].color;
         f[*t].change=f[*t+].change=;
         f[t].change=;
     }
     ;
     *t,l,r);
     else
     {
         *t+,l,r);
         else
         {
             *t,l,mid);
             *t+,mid+,r);
             return t1|t2;
         }
     }
 }
 void update(int t,int l,int r,int c)
 {
     if (f[t].l==l && f[t].r==r)
     {
         f[t].change=;
         f[t].color=<<c;
         return ;
     }
     )
     {
         f[*t].color=f[t].color;
         f[*t+].color=f[t].color;
         f[t].change=;
         f[*t].change=f[*t+].change=;
     }
     ;
     *t,l,r,c);
     else
     {
         *t+,l,r,c);
         else
         {
             update(*t,l,mid,c);
             update(*t+,mid+,r,c);
         }
     }
     f[t].color=f[*t].color|f[*t+].color;
 }
 int n;
 int T;
 int Q;
 ];
 int x,y,c;
 void swap(int &x,int &y)
 {
     int t=x;
     x=y;
     y=t;
 }
 void slove()
 {
     build(,,n);
     ;i<=Q;i++)
     {
         scanf("%s",s);
         ]=='C')
         {
             scanf("%d%d%d",&x,&y,&c);
             if (x>y) swap(x,y);
             update(,x,y,c);
         }
         else
         {
             scanf("%d%d",&x,&y);
             if (x>y) swap(x,y);
             ,x,y);
             ;
             )
             {
                 ans++;
                 t-=(t&(-t));
             }
             printf("%d\n",ans);
         }
     }
 }
 int main()
 {
     while (scanf("%d%d%d",&n,&T,&Q)!=EOF)
     {
         slove();
     }
     ;
 }

poj2777 线段树的更多相关文章

  1. poj-2777线段树刷题

    title: poj-2777线段树刷题 date: 2018-10-16 20:01:07 tags: acm 刷题 categories: ACM-线段树 概述 这道题是一道线段树的染色问题,,, ...

  2. Count Color poj2777 线段树

    Count Color poj2777 线段树 题意 有一个长木板,现在往上面在一定区间内刷颜色,后来刷的颜色会掩盖掉前面刷的颜色,问每次一定区间内可以看到多少种颜色. 解题思路 这里使用线段树,因为 ...

  3. POJ2777(线段树涂色问题)

    Count Color Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 42828   Accepted: 12973 Des ...

  4. poj2777(线段树)

    题目链接:https://vjudge.net/problem/POJ-2777 题意:有L块连续的板子,每块板子最多染一种颜色,有T种(<=30)颜色,刚开始将所有板子染成颜色1,O次操作(包 ...

  5. Count Color(线段树+位运算 POJ2777)

    Count Color Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 39917 Accepted: 12037 Descrip ...

  6. [POJ2777]Count Color(线段树)

    题目链接:http://poj.org/problem?id=2777 给你一个长为L想线段,向上面染色,颜色不超过30种,一共有O次操作,操作有两种: C a b c 在[a,b]上染上c颜色 P ...

  7. POJ-2777 Count Color(线段树,区间染色问题)

    Count Color Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 40510 Accepted: 12215 Descrip ...

  8. 几道简单的线段树入门题 POJ3264&&POJ3468&&POJ2777

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 40687   Accepted: 19137 ...

  9. POJ 2777(线段树)

    Count Color Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 42507   Accepted: 12856 Des ...

随机推荐

  1. Appium 切换上下文环境

    Appium 切换上下文环境,代码如下: private void switchToContext(String sContext) { LogManager.getLogger(this.getCl ...

  2. android动画小析

    这里所讲的动画,是android framework提供的动画框架里面的动画. 是view层级的动画.不涉及到底层opengl es相关的动画实现. 动画: 主要包括 Interpolation du ...

  3. Java并发编程:并发容器之CopyOnWriteArrayList

    转载: Java并发编程:并发容器之CopyOnWriteArrayList Copy-On-Write简称COW,是一种用于程序设计中的优化策略.其基本思路是,从一开始大家都在共享同一个内容,当某个 ...

  4. js和jquery获取子元素

    <ul id="nav"> <li></li> <li> <ul> <li></li> < ...

  5. 你不知道的JavaScript-- 事件流与事件处理

    转载:http://blog.csdn.net/i10630226/article/details/48970971 1. 事件处理 1.1. 绑定事件方式 (1)行内绑定 语法: //最常用的使用方 ...

  6. 移动前端开发的viewport总结整理

    1.通俗讲移动设备上的viewport就是设备的屏幕上能用来显示我们的网页的那块区域,但不是浏览器可视区域.一般来讲,移动设备上的viewport都要大于浏览器的可视区域.移动设备上的浏览器会把默认的 ...

  7. 5月11日 ArrayList集合复习、特殊集合、枚举类型

    一.ArrayList集合复习 //定义 ArrayList al = new ArrayList(); //添加元素 al.Add(); //插入元素 al.Insert(,); //查看个数 in ...

  8. 使用Yeoman,Grunt和Bower开发AngularJS(译)

    使用Yeoman产生AngularJS的主要骨架 使用Grunt加速开发和帮助执行 使用Bower来加入第三方插件和框架——third party plugins/frameworks 一.准备工作 ...

  9. 布隆过滤器(Bloom Filter)详解——基于多hash的概率查找思想

    转自:http://www.cnblogs.com/haippy/archive/2012/07/13/2590351.html   布隆过滤器[1](Bloom Filter)是由布隆(Burton ...

  10. sqlserver获取表名,字段名

    一.获取表的基本信息 SELECT [TableName] = [Tables].name , [TableOwner] = [Schemas].name , [TableCreateDate] = ...