//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. 获取AVCaptureSession samplebuffer 一像素的 rgb值

    获取AVCaptureSession samplebuffer 一像素的 rgb值 typedef unsigned char byte; typedef struct RGBPixel{ byte ...

  2. 如何编写跨平台的Java代码

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  3. Windows日志查看工具合集

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://github.com/jiangxincode 知乎地址 ...

  4. eclipse插件在线发布发布和版本更新(web site) 转

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju/p/4781259.html GitHub地址: https://github.com/ji ...

  5. 5.6 WebDriver API实例讲解(31-35)

    31.判断页面元素是否存在 public static void testElementExist(){ driver.get("http://www.sogou.com"); t ...

  6. robotframework笔记10

    循环和条件 for循环 *** Settings *** Library BuiltIn Library Collections *** Test Cases *** TestCase01 My Ke ...

  7. 联系 管理 Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(三)

    hibernate注解实体类示例 package cn.bdqn.smvc.entity; import java.io.Serializable; import javax.persistence. ...

  8. word linkage 选择合适的聚类个数matlab code

    clear load fisheriris X = meas; m = size(X,2); % load machine % load census % % X = meas; % X=X(1:20 ...

  9. Oracle存储过程写法

    create or replace procedure QIANFEIGL_JIAOKUANDY( cebenh varchar2, kehuh varchar2, hetongh varchar2, ...

  10. CENTOS6 安装配置 pptpd 心得

    1.你所需要的软件 pppd    ppp拨号服务器pptpd   在pppd拨号的基础上增加pptpd的支持 2.确定你的内核是否支持mppe modprobe ppp-compress-18 &a ...