离散化 + 线段树

#include 
#include 
#include 
#include 
#include 

using namespace std;
#define maxn 200000 + 10
#define lson L, mid, rt<<1
#define rson mid, R, rt<<1|1

int X1[maxn], X2[maxn];
int n;
int lazy[maxn<<2];
int mark[maxn];

int compress(int *x1, int *x2)
{
    vector x;

    for(int i=0; i> 1;
    if(lazy[rt]) pushdown(L, R, rt);

    if(r <= mid) update(l, r, v, lson);
    else if(l >= mid) update(l, r, v, rson);
    else
    {
        update(l, mid, v, lson);
        update(mid, r, v, rson);
    }
}

void traverse(int L, int R, int rt)
{
    if(L+1 == R)
    {
        mark[L] = lazy[rt];
        return ;
    }

    int mid = (L + R) >> 1;
    if(lazy[rt]) pushdown(L, R, rt);
    traverse(lson);
    traverse(rson);
}

void solve()
{
    int w = compress(X1, X2);
    int num = 0;
    for(int i=0; i

你可能感兴趣的:(线段树,水题)