读错题意了。。线段树延迟标记

白刷这么多线段树

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define N 300010
int s[N<<],la[N<<];
struct node
{
int l,r,d;
}q[N];
void update(int a,int b,int p,int l,int r,int w)
{
if(a<=l&&b>=r)
{
s[w] = p;
return ;
}
if(s[w])
{
s[w<<] = s[w<<|] = s[w];
s[w] = ;
}
int m = (l+r)>>;
if(a<=m)
update(a,b,p,l,m,w<<);
if(b>m)
update(a,b,p,m+,r,w<<|);
}
int query(int k,int l,int r,int w)
{
if(l==r)
return s[w];
if(s[w])
s[w<<] = s[w<<|] = s[w];
int m = (l+r)>>;
if(k<=m)
return query(k,l,m,w<<);
else
return query(k,m+,r,w<<|);
}
int main()
{
int i,n,m;
int a,b,c;
scanf("%d%d",&n,&m);
for(i = ; i <= m ;i++)
{
scanf("%d%d%d",&q[i].l,&q[i].r,&q[i].d);
}
for(i = m ; i >= ; i--)
{
a = q[i].l;b = q[i].r; c = q[i].d;
if(a!=c)
update(a,c-,c,,n,);
if(b!=c)
update(c+,b,c,,n,);
}
for(i = ; i < n ; i++)
printf("%d ",query(i,,n,));
printf("%d\n",query(n,,n,));
return ;
}

Codeforces Round #207 (Div. 2)C的更多相关文章

  1. Codeforces Round #207 (Div. 1) A. Knight Tournament (线段树离线)

    题目:http://codeforces.com/problemset/problem/356/A 题意:首先给你n,m,代表有n个人还有m次描述,下面m行,每行l,r,x,代表l到r这个区间都被x所 ...

  2. Codeforces Round #207 (Div. 1) A. Knight Tournament(STL)

    脑子又卡了...来一发set的,STL真心不熟. #include <stdio.h> #include <string.h> #include <iostream> ...

  3. Codeforces Round #207 (Div. 2) A. Group of Students

    #include <iostream> #include <vector> using namespace std; int main(){ ; cin >> m ...

  4. Codeforces Round #207 (Div. 1)B(数学)

    数学so奇妙.. 这题肯定会有一个循环节 就是最小公倍数 对于公倍数内的相同的数的判断 就要借助最大公约数了 想想可以想明白 #include <iostream> #include< ...

  5. Codeforces Round #207 (Div. 2)

    A:超级大水题: 代码: #include<cstdio> #define maxn 105 using namespace std; int n,a[maxn],x,y,ans; int ...

  6. Codeforces Round #207 (Div. 1) B. Xenia and Hamming(gcd的运用)

    题目链接: B. Xenia and Hamming 题意: 要求找到复制后的两个字符串中不同样的字符 思路: 子问题: 在两串长度是最大公倍数的情况下, 求出一个串在还有一个串中反复字符的个数 CO ...

  7. Codeforces Round #207 (Div. 1) D - Bags and Coins 构造 + bitset优化dp + 分段查找优化空间

    D - Bags and Coins 思路:我们可以这样构造,最大的那个肯定是作为以一个树根,所以我们只要找到一个序列a1 + a2 + a3 .... + ak 并且ak为 所有点中最大的那个,那么 ...

  8. Codeforces Round #207 (Div. 2)A B C E 水 思路 set 恶心分类

    A. Group of Students time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #207 (Div. 1) B (gcd的巧妙运用)

    比赛的时候不知道怎么写... 太弱了. 看了别人的代码,觉得这个是个经典的知识点吧. gcd的巧妙运用 自己想的时候苦苦思考怎么用dp求解. 无奈字符串太长而想不出好的算法. 其实在把a和b字符串都分 ...

随机推荐

  1. Fibonacci数

    Fibonacci数 时间限制:3000 ms  |  内存限制:65535 KB 难度:1   描述 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递 ...

  2. 从InputStream到String_写成函数

    String result = readFromInputStream(inputStream);//调用处 //将输入流InputStream变为String public String readF ...

  3. C++中const关键字详解

    1.什么是const? const意味着是常量类型,被const修饰的变量或对象是不能被修改和更新的,当然在某些情况下,我们可以偷梁换柱的改变它. 2.为什么要引入const? 最初的目的是为了取代预 ...

  4. Python random模块 例子

    最近用到随机数,就查询资料总结了一下Python random模块(获取随机数)常用方法和使用例子. 1.random.random  random.random()用于生成一个0到1的随机符点数: ...

  5. C# - 设置DLL的属性Embed Interop Type 设为False

    错误: Error msg: A reference was created to embedded interop assembly. because of an indirect referenc ...

  6. 20160729noip模拟赛zld

    首先显然有多少个奇数,就有多少个回文串是最优的(没有奇数时构造一个回文串 然后有了k个“核心”,把剩下的字符顺序安排到这些的两侧,最后最短的回文串长度就是答案 #include<map> ...

  7. SQL Server 之 锁

    锁,是由锁管理器负责维护,其目的是保证事务的ACID,是平衡并发和数据安全的机制. 锁定粒度与并发性是成反比的,默认情况下,SQL Server Compact 4.0 对数据页使用行级锁定,对索引页 ...

  8. Web App之一

    JSP/HTML/CSS---------View(不包含任何的数据,只作为基本的layout) JS------------------------Data(update JSP/HTML)

  9. HTTP请求报文与响应报文

    http://docs.telerik.com/fiddler/KnowledgeBase/HTTP HTTP请求报文与响应报文 HTTP http://www.w3.org/Protocols/rf ...

  10. 盘点 DevOps 世界的杰出女性(一)

    [编者按]IT 领域从来不缺乏杰出的女性存在,近日,DevOps.com 主编 Alan Shimel 盘点了 DevOps 领域的杰出女性,首期为六个,本文系 OneAPM 工程师编译整理. 以下为 ...