http://codeforces.com/contest/357/problem/C

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 300010
using namespace std; int n,m;
int l1,r1,x1;
struct node
{
int l,r;
int cover;
}tree[maxn*];
int x[maxn]; void build(int i,int l,int r)
{
tree[i].l=l;tree[i].r=r;
tree[i].cover=;
if(l==r) return ;
int mid=(l+r)>>;
build(i<<,l,mid);
build(i<<|,mid+,r);
}
void down(int i)
{
if(tree[i].l==tree[i].r) return ;
if(tree[i].cover>)
{
if(tree[i<<].cover==)
tree[i<<].cover=tree[i].cover;
if(tree[i<<|].cover==)
tree[i<<|].cover=tree[i].cover;
tree[i].cover=-;
}
}
void update(int i,int l,int r,int co)
{
if(tree[i].l==l&&tree[i].r==r)
{
if(tree[i].cover==)
{
tree[i].cover=co;
}
return ;
}
down(i);
int mid=(tree[i].l+tree[i].r)>>;
if(r<=mid)
{
update(i<<,l,r,co);
}
else if(l>mid)
{
update(i<<|,l,r,co);
}
else
{
update(i<<,l,mid,co);
update(i<<|,mid+,r,co);
}
} void search1(int i)
{
if(tree[i].l==tree[i].r)
{
x[tree[i].l]=tree[i].cover;
return;
}
down(i);
search1(i<<);
search1(i<<|);
} int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
build(,,n);
memset(x,,sizeof(x));
for(int i=; i<=m; i++)
{
scanf("%d%d%d",&l1,&r1,&x1);
if(l1==x1){
update(,l1+,r1,x1);
}
else if(r1==x1)
{
update(,l1,r1-,x1);
}
else
{
update(,l1,x1-,x1);
update(,x1+,r1,x1);
}
}
search1();
for(int i=; i<=n; i++)
{
if(i==)
printf("%d",x[i]);
else
printf(" %d",x[i]);
}
printf("\n");
}
return ;
}

cf C. Knight Tournament的更多相关文章

  1. CF 628A --- Tennis Tournament --- 水题

    CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...

  2. CodeForce 356A Knight Tournament(set应用)

     Knight Tournament time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  3. Knight Tournament 合并区间

    Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the me ...

  4. Knight Tournament (set)

    Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the me ...

  5. CodeForces - 357C Knight Tournament 伪并查集(区间合并)

    Knight Tournament Hooray! Berl II, the king of Berland is making a knight tournament. The king has a ...

  6. D - Knight Tournament(set)

    Problem description Hooray! Berl II, the king of Berland is making a knight tournament. The king has ...

  7. codeforces 357C Knight Tournament(set)

    Description Hooray! Berl II, the king of Berland is making a knight tournament. The king has already ...

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

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

  9. Knight Tournament

    Codeforces Round #207 (Div. 1) A:http://codeforces.com/problemset/problem/356/A 题意:给你n匹马,然后有m场比赛.每场比 ...

随机推荐

  1. In App Purchases(IAP 应用程序內购买): 完全攻略

    原文: http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/ 参考: http://www.cocoachina ...

  2. 设计模式 ( 十八 ):State状态模式 -- 行为型

    1.概述 在软件开发过程中,应用程序可能会根据不同的情况作出不同的处理.最直接的解决方案是将这些所有可能发生的情况全都考虑到.然后使用if... ellse语句来做状态判断来进行不同情况的处理.但是对 ...

  3. Linux桌面快捷方式建立方案

    Linux桌面快捷方式建立方案 以下以添加Eclips为例 在桌面上添加Eclips.desktop 文件,向其写入如下代码 [Desktop Entry] Name=Eclipse Comment= ...

  4. URAL 2034 : Caravans

    Description   Student Ilya often skips his classes at the university. His friends criticize him for ...

  5. 实现函数 isInteger(x) 来判断 x 是否是整数

    将x转换为十进制整数,判断是否和自身相等即可: function isInteger(x){ return parseInt(x, 10) === x; } console.log('1.2 is a ...

  6. eCharts的随笔

    1.散点图中找最优记录 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&q ...

  7. linux下解压压缩rar文件

    http://download.csdn.net/detail/hnust_xiehonghao/6679893   下载地址 1. 下载软件 以rarlinux-3.8.0 for linux为例, ...

  8. css的小demo

    demo1 一个高度随宽度变化的正方形   (缩小屏幕试试) 原理:margin和padding如果是用百分比设置,则是以父元素的宽度的百分比设置的. .Square{ display: inline ...

  9. 2d-x中Lua类型强转问题

    在Lua中,使用CCDictionary进行保存CCSprite对象,但是,在CCDictionary取出来的时候,此时是一个CCObject对象,无法调用子类精灵的一些方法.那只能进行强转的. 那么 ...

  10. js获取每个按键的ASCII值

    通过js绑定键盘按下事件onkeydown获取每个按键的ascII值. js获取每个按键的ascii值 <script language="javascript"> / ...