C++
1.
#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;
const int max_N=2000000;
int N,K;
int tree[max_N*4][2];
void update(int t[2], int t2[2])
{
if(t2[0] > t[1])
t[0] = t[1] = t2[0];
else if(t2[1] < t[0])
t[0] = t[1] = t2[1];
else
{
t[0] = max(t[0], t2[0]);
t[1] = min(t[1], t2[1]);
}
}
void lazy_(int idx,int s,int e){
if(s!=e){
update(tree[idx << 1], tree[idx]);
update(tree[(idx << 1) | 1], tree[idx]);
tree[idx][0]=0;
tree[idx][1]=INT_MAX;
return;
}
}
void update(int idx,int s,int e,int op,int l,int r,int h){
lazy_(idx,s,e);
if(r < s || l > e)
return ;
if(l<=s&&e<=r){
if(op-1){
int t[2] = { 0, h};
update(tree[idx], t);
}else{
int t[2] = { h, INT_MAX};
update(tree[idx], t);
}
return;
}
int mid=(s+e)/2;
update(idx<<1,s,mid,op,l,r,h);
update((idx<<1)|1,mid+1,e,op,l,r,h);
}
void print(int idx,int s,int e){
lazy_(idx,s,e);
if(s==e){
printf("%d\n",tree[idx][0]);
return;
}
int mid=(s+e)/2;
print(idx<<1,s,mid);
print((idx<<1)|1,mid+1,e);
}
int main()
{
scanf("%d %d",&N,&K);
for(int i=1;i<=K;i++){
int op,l,r,h;
scanf("%d %d %d %d",&op,&l,&r,&h);
update(1,0,N-1,op,l,r,h);
}
print(1,0,N-1);
return 0;
}
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
공지 | 안내사항 | 관리자 | 2019.12.21 | 165 |
15 | 14430 | 관리자 | 2019.12.21 | 6 |
14 | 1182 | 관리자 | 2019.12.21 | 8 |
13 | 11660 | 관리자 | 2020.04.11 | 46 |
12 | 1149 | 관리자 | 2019.12.21 | 8 |
11 | 10999 | 관리자 | 2020.04.11 | 47 |
10 | 10937 | 관리자 | 2020.04.11 | 41 |
9 | 10919 | 관리자 | 2020.04.11 | 42 |
8 | 10800 | 관리자 | 2019.12.21 | 8 |
7 | 10799 | 관리자 | 2019.12.21 | 9 |
6 | 10534 | 관리자 | 2020.04.11 | 44 |
5 | 10164 | 관리자 | 2019.12.21 | 6 |
4 | 10159 | 관리자 | 2019.12.21 | 6 |
3 | 10157 | 관리자 | 2019.12.21 | 8 |
» | 10070 | 관리자 | 2020.04.11 | 44 |
1 | 1005 | 관리자 | 2019.12.21 | 8 |