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字符串都分 ...
随机推荐
- 【python】网络爬虫抓取图片
利用python抓取网络图片的步骤: 1.根据给定的网址获取网页源代码 2.利用正则表达式把源代码中的图片地址过滤出来 3.根据过滤出来的图片地址下载网络图片 今天我们用http://www.umei ...
- Daject初探 - 从Table模型得到Record模型
前言: 如果你还不知道Daject是什么,如何使用,可以浏览 http://www.cnblogs.com/kason/p/3577359.html github地址:https://github.c ...
- UML 小结(1)- 整体阐述
前言: UML( Unified Modeling Language) 又称统一建模语言或标准建模语言,是始于1997年一个OMG标准,它是一个支持模型化和软件系统开发的图形 ...
- Leetcode-Read N Characters Given Read4 II
The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actu ...
- ifame 跨域高度自适应
代码如下:var iframeids = ['memberIndexIframe','inquiryCenterIframe','everychinaBbsIframe']; var iframehi ...
- Module模式 - 深入了解Javascript
/* Modelu模式 优点:效率高,代码少,加载速度快,松耦合允许并行加载,提升下载速度 缺点:初始化时间久一点 */ //一.基础用法 var calculate = function (eq) ...
- 常用sqlserver语句
1.查看表上的索引 sp_helpIndex [表名] --查询表上拥有的索引 2.更新其它表 update 申请信息set 研发部门='123',版本信息='321'where 单号=(selec ...
- NYOJ-32 组合数 AC 分类: NYOJ 2014-01-02 22:21 112人阅读 评论(0) 收藏
#include<stdio.h> int num[100]; int pnum(int n,int v); int mv=0; int main(){ int n,v; scanf(&q ...
- CentOS安装RockMongo
rockmongo官网下载页面在这里: http://rockmongo.com/downloads 找到最新版本的下载链接,一般第一个就是: 右键复制url,比如说是这个: http://rockm ...
- error C2061: syntax error : identifier '__RPC__out_xcount_part'
朋友遇到的 把dx, windows sdk ,vs2010照着成功人士的配置好 应该就可以了