//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. SAP MM移动平均价和标准价逻辑

    从收货到领用,S一直都是以标准价格计算,V是实时更新 S 时将差异结转到在产品,产品中,最后结转到生产成本,最终到利润.具有计划性,可以控制考核 V 是实时更新,出现差异直接对应材料中调整.价格可以直 ...

  2. python 练习 20

    #!/usr/bin/python # -*- coding: UTF-8 -*- from sys import stdout n = int(raw_input("input numbe ...

  3. python读取指定内存的内容

    import ctypes as ct t = ct.string_at(0x211000, 20) # (addr, size) print t 最好不要用解释性语言来开发底层,一般用C.

  4. Hive的Security配置

    为了更好地使用好Hive,我将<Programming Hive>的Security章节取出来,翻译了一下. Hive还是支持相当多的权限管理功能,满足一般数据仓库的使用. Hive由一个 ...

  5. hive分区导致FAILED: Hive Internal Error: java.lang.NullPointerException(null)

    写了一条hive sql ,其中条件中存在 dt>=20150101 and dt<=20150228 这样的条件,原来执行没问题,今天就抛出 FAILED: Hive Internal ...

  6. Facebook 内部高效工作PPT

    Facebook 内部分享:不论你如何富有,你都赚不到更多的时间,你也回不到过去.没有那么多的假如,只有指针滴答的时光飞逝和你应该好好把握的现在,以下26张PPT的分享将为您带来时间价值管理的技巧. ...

  7. if条件语句练习题

    习题一: 做一个算缘分的小游戏:输入男方姓名,女方姓名,输出缘分指数,给出建议. static void Main(string[] args) { //做一个算缘分的小游戏: //输入男方姓名,女方 ...

  8. Objective-C( 语法一)

    点语法 点语法的本质是方法调用 成员变量的作用域 @public : 在任何地方都能直接访问对象的成员变量 @private : 只能在当前类的对象方法中直接访问(@implementation中默认 ...

  9. das,nas,san区别——大型数据中心会用NAS+SAN软硬结合思路

    DAS(Direct Access Storage-直接连接存储)是指将存储设备通过SCSI接口或光纤通道直接连接到一台计算机上.NAS(Network Attached Storage网络连接存储) ...

  10. 编程思考 PetShop读后感

    标准,插拔式的设计思想建立一致的标准是通向“复用”的通道.分层,使其得到的充分的独立.一个东西如果独立了[不是孤立],这个事物就具有很强大的力量,这个和一个人的成长是相同的道理.所以呢,在写程序的过程 ...