/**
poj 3667 hotel
问题描述,一排房子,住进或清空;
住进,从左面开始找一段满足条件的房子,住进靠左的一段连续的房子内
清空,将房子[x , x + d - 1]的房子清空
*/
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define N 50005
#define L(r) r << 1
#define R(r) r << 1 | 1
struct _st
{
int l,r,
l_max, ///左结点起最大连续空余
r_max, ///右结点结尾的最大连续空余
maxx, ///区间内的最大连续空间
cover; /// 0 表示未被占用,1表示被占用;-1表示二者皆有
int mid()
{
return (l + r) >> 1;
}
}st[N << 2];
void build(int rt,int l,int r)
{
st[rt].l = l;
st[rt].r = r;
st[rt].l_max = st[rt].r_max = st[rt].maxx = (r - l + 1);
st[rt].cover = 0;
if(l != r)
{
poj 3667 hotel #线段树
最新推荐文章于 2021-09-24 12:35:25 发布