Codeforces Round #207 (Div. 2)C
读错题意了。。线段树延迟标记
白刷这么多线段树
#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的更多相关文章
- 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所 ...
- Codeforces Round #207 (Div. 1) A. Knight Tournament(STL)
脑子又卡了...来一发set的,STL真心不熟. #include <stdio.h> #include <string.h> #include <iostream> ...
- Codeforces Round #207 (Div. 2) A. Group of Students
#include <iostream> #include <vector> using namespace std; int main(){ ; cin >> m ...
- Codeforces Round #207 (Div. 1)B(数学)
数学so奇妙.. 这题肯定会有一个循环节 就是最小公倍数 对于公倍数内的相同的数的判断 就要借助最大公约数了 想想可以想明白 #include <iostream> #include< ...
- Codeforces Round #207 (Div. 2)
A:超级大水题: 代码: #include<cstdio> #define maxn 105 using namespace std; int n,a[maxn],x,y,ans; int ...
- Codeforces Round #207 (Div. 1) B. Xenia and Hamming(gcd的运用)
题目链接: B. Xenia and Hamming 题意: 要求找到复制后的两个字符串中不同样的字符 思路: 子问题: 在两串长度是最大公倍数的情况下, 求出一个串在还有一个串中反复字符的个数 CO ...
- Codeforces Round #207 (Div. 1) D - Bags and Coins 构造 + bitset优化dp + 分段查找优化空间
D - Bags and Coins 思路:我们可以这样构造,最大的那个肯定是作为以一个树根,所以我们只要找到一个序列a1 + a2 + a3 .... + ak 并且ak为 所有点中最大的那个,那么 ...
- 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 ...
- Codeforces Round #207 (Div. 1) B (gcd的巧妙运用)
比赛的时候不知道怎么写... 太弱了. 看了别人的代码,觉得这个是个经典的知识点吧. gcd的巧妙运用 自己想的时候苦苦思考怎么用dp求解. 无奈字符串太长而想不出好的算法. 其实在把a和b字符串都分 ...
随机推荐
- SqlServer里DateTime转字符串
Select CONVERT(varchar(100), GETDATE(), 8):14:53:14 Select CONVERT(varchar(100), GETDATE(), 9): 06 ...
- OC self super isa指针
self指针: self是oc面向对象设计中的一个特殊指针,相当于java中的this,但是比this强大,this只能访问实例对象的相关方法和成员变量,或者说this只代表实例对象: self不仅可 ...
- java集合类(四)About Set
接上篇:java集合类(三)About Iterator & Vector(Stack) 之前,在比较java常见集合类的时候,就了解到一点有关Set的特性.实现类及其要求等,读者可以去温习下 ...
- c++ 如何实现,readonly
需求: 我要实现一个常量字段,只能赋值一次,赋值后不容许更改. 类似于c#的readonly或者java final #include <iostream> class A{public ...
- 项目中的libevent
单线程libevent模式 项目里面是多线程版的,我先理解下单线程的. //client .调用NGP::init() bool NGP::init(NGPcontext context) { _co ...
- SQLServer 触发器 同时插入多条记录有关问题
由于 SQL Server 的触发器, 没有 FOR EACH ROW (ORACL中有)的选项, 有时候不正确的使用 inserted 与deleted 可能会有点麻烦. 下面来一个简单的例子 -- ...
- LoadRunner 11 安装及破解(转)
前提条件: 内存:2G,硬盘空闲空间10G,安装完成后实际只占不到2G 支持winXP SP3;32位与64位win7浏览器支持IE6-8,IE9,firefox3 若以前安装过LoadRunner ...
- 【系统Configmachine.config与自己的应用程序的App.config/Web.Config配置节点重复】解决方法
自己的应用程序的App.config或Web.Config文件中与系统的C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Configmachine.co ...
- Window 8.1 开启Wifi共享
p{padding-left:20px;} Hosted network supported:Yes 支持Wifi共享 命令:netsh wlan set hostednetwork mode=al ...
- PHP字符串中的变量解析(+教你如何在PHP字符串中加入变量)
定义字符串的时候,用单引号或者双引号都是可以的.我个人习惯是用双引号.在输出字符串的时候,若字符串中含有字符串变量,使用单引号和双引号则是有区别的.如下面程序: 1 2 3 4 5 6 7 8 < ...