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. Graphviz-Gdot语言学习

    GVEdit这个绘图软件呢我也是刚接触的,感觉画起图来还是很爽的...尤其很熟悉c++后很容易上手这门dot语言. 先看一下十分清新的编程界面: 没有天下最邪恶的语法加亮,没有缩进行...这又算什么! ...

  2. HDOJ 1061 Rightmost Digit(循环问题)

    Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...

  3. 数据库版本管理工具Flyway(4.0.3)---介绍(译文)

    Flyway Evolve your Database Schema easily and reliably across all your instances 简单的.可靠的升级(发展)你的数据库模 ...

  4. JS-事件处理

    1.一个简单的单击事件: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  5. JS(四)

    JS的属性好多,方法好多,一下子塞进来真的需要时间消化,很多东西都是当时记得很清楚,但忘得很快,看来需要经常去复习,主要是感觉后面一点的练习题好像少了点,所以就显得不是很熟练. 1.About Tim ...

  6. SEO学习之路

    一.入门建站篇 1.Wamp集成环境安装 2.Wamp集成环境配置多站点 3.DedeCMS安装及目录结构 4.DedeCMS源码安装 5.DedeCMS官方手册 未完待续...

  7. 在jsp页面上直接打开PDF文件

    1.在不需要使用插件,直接打开通过链接方式打开 <%@ page language="java" import="java.util.*,java.io.*&quo ...

  8. Java当中的运算符

    一.关于Java当中运算符的分类 算术运算符:+,-,*,/.%(是取余运算符读莫).++.-- 关系运算符:>.<.>=.<=.!=(不等).==(等于) 布尔运算符:!(非 ...

  9. mvc中使用jsonp进行跨域请求详细说明

    在web开发中,如果你要在不同域下进行数据异步请求,会出现一个No ‘Access-Control-Allow-Origin’ header is present on the requested r ...

  10. Velocity 语法示例

    一.简介: 1)它允许任何人使用简单而强大的模板语言来引用定义在 java 代码中的对象" 2)Velocity是一个基于java的模板引擎,简称VTL(Velocity Template ...