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的更多相关文章
-
CF 628A --- Tennis Tournament --- 水题
CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...
-
CodeForce 356A Knight Tournament(set应用)
Knight Tournament time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
-
Knight Tournament 合并区间
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the me ...
-
Knight Tournament (set)
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the me ...
-
CodeForces - 357C Knight Tournament 伪并查集(区间合并)
Knight Tournament Hooray! Berl II, the king of Berland is making a knight tournament. The king has a ...
-
D - Knight Tournament(set)
Problem description Hooray! Berl II, the king of Berland is making a knight tournament. The king has ...
-
codeforces 357C Knight Tournament(set)
Description Hooray! Berl II, the king of Berland is making a knight tournament. The king has already ...
-
Codeforces Round #207 (Div. 1) A. Knight Tournament(STL)
脑子又卡了...来一发set的,STL真心不熟. #include <stdio.h> #include <string.h> #include <iostream> ...
-
Knight Tournament
Codeforces Round #207 (Div. 1) A:http://codeforces.com/problemset/problem/356/A 题意:给你n匹马,然后有m场比赛.每场比 ...
随机推荐
-
判断日期是否符合yyyy-mm格式
!Regex.IsMatch(dr["DMAKEDATE"].ToString(),@"^(?<year>\\d{2,4})-(?<month>\ ...
-
Logstash+kibana+ ElasticSearch+redis
这是之前Logstash+kibana+ ElasticSearch+redis 安装时,自己整理的初学者容易看懂的资料,按照以下的步骤也已经完成了安装. 这里有二台服务器: 192.168.148. ...
-
SOLVED: GATT callback fails to register
I finally figured this problem out. The device I am using is a Samsung Galaxy S4 and the actual prob ...
-
hdu3652B-number
Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal for ...
-
Linux下使用多线程模拟异步网络通信
服务器 /* socket server * 2014-12-15 CopyRight (c) arbboter */ #include <unistd.h> #include <s ...
-
iOS 键盘弹出遮挡输入框
#pragma mark 键盘弹出遮挡输入框 //开始编辑输入框的时候,软键盘出现,执行此事件 -(void)textFieldDidBeginEditing:(UITextField *)textF ...
-
Windows下安装Confluence并破解汉化
注:本文来源于<Windows下安装Confluence并破解汉化> 一.事前准备 1:JDK下载并安装:jdk-6u45-windows-i586.exe 2:MySQL JDBC连接驱 ...
-
缩点:Power Plant;
题目传送门:[UVALive 6437]Power Plant 题目大意:T组数据,给定一幅带权图(n, m), 然后给定k个点, 与图中存在有若干条边.每个点都要至少要和这k个点的一个点直接或间接相 ...
-
C# Enum枚举类型操作扩展类
使用示例: using System.ComponentModel; namespace SchoolEnterpriseManageSys.Enum { /// <summary> // ...
-
java基础学习总结——Object类
一.Object类介绍