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字符串都分 ...
随机推荐
- Java对象的序列化与反序列化
序列化与反序列化 序列化 (Serialization)是将对象的状态信息转换为可以存储或传输的形式的过程.一般将一个对象存储至一个储存媒介,例如档案或是记亿体缓冲等.在网络传输过程中,可以是字节或是 ...
- 显示 mac 隐藏文件
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏Mac隐藏文件的命令:defaults writ ...
- Ubuntu 12.4 下升级 Subversion 1.7
Ubuntu 12.04 默认使用的是Subversion 1.6,而Ubutnu12.10开始,就使用的是Subversion 1.7. 如果从别人的地方拷过来的SVN目录,在使用SVN命令时会报以 ...
- 不安装Oracle客户端远程连接Orcale数据库
本方法是通过使用ORACLE官方提供的精简版客户端,即绿色免安装的客户端. 下载地址(此处提供的是官方各版本下载地址): Windows 32位系统中使用的客户端下载地址其他系统环境中使用的客户端下载 ...
- android.os.DeadObjectException memory near r0: 异常处理 Consumer closed input channel or an error occurred. events=0x9
原地址:http://www.cnblogs.com/wanqieddy/p/3495338.html android.os.DeadObjectException memory near r0: 异 ...
- [转载]Spring Beans Auto-Wiring
Autowiring Modes You have learnt how to declare beans using the <bean> element and inject < ...
- hdu 1596 find the safest road(最短路,模版题)
题目 这是用Dijsktra做的,稍加改动就好,1000ms..好水.. #define _CRT_SECURE_NO_WARNINGS #include<string.h> #inclu ...
- [转]Ubuntu alternate和desktop区别
原文地址:http://blog.csdn.net/is2120/article/details/6797621 Desktop : 刻录在光盘,从光盘运行的系统,相当于 Live CD Altern ...
- @QueryParam和@PathParam比较
来源:http://jackyrong.iteye.com/blog/1128364 1 先来看@queryparam Path("/users") public class Us ...
- Project Euler 81:Path sum: two ways 路径和:两个方向
Path sum: two ways In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom ...