SCOI2010 序列操作

2022-05-20 09:55:31 字數 1454 閱讀 8263

我可以銘記一生的蛇皮線段樹

左左右右上上下下中間兩頭

咳咳,沒什麼好說的了,開始寫吧。

我,可真是,寫了zz三天。

#include #include #includeusing namespace std;

struct ans

};int n, q,a[4000101];

int sum[4000101], l1[4000101], r1[4000101], l0[4000101], r0[4000101];

int lg1[4000101], lg0[4000101],add1[4000101], add2[4000101];

void pushup(int rt, int l, int r)

void pushdown(int rt, int ln, int rn)

if(add2[rt])

}void build(int rt, int l, int r)

int mid =l + r >> 1;

build(rt<<1,l,mid);

build(rt<<1|1,mid+1,r);

pushup(rt,l,r);

}void modify(int rt, int l, int r, int l, int r, int c)

int mid=l+r>>1;

pushdown(rt,mid-l+1,r-mid);

if(mid>=l)modify(rt<<1,l,mid,l,r,c);

if(mid>1;

pushdown(rt,mid-l+1,r-mid);

if(mid>=l)reverse_(rt << 1,l,mid, l, r);

if(mid>1;

pushdown(rt,mid-l+1,r-mid);

int ans=0;

if(mid>=l)ans+=query1(rt << 1, l, mid, l, r);

if(mid> 1;

pushdown(rt,mid-l+1,r-mid);

if(r <= mid)return query2(rt << 1, l, mid, l, r);

if(l > mid)return query2(rt << 1 | 1, mid + 1, r, l, r);

ans al=query2(rt << 1,l,mid,l,mid);

ans ar=query2(rt<<1 | 1, mid+1,r,mid+1, r);

return ans((al.l==al.len?al.l+ar.l:al.l),(ar.r == ar.len?ar.r+al.r:ar.r),max(max(al.ans,ar.ans),al.r+ar.l),al.len+ar.len);//全場最坑

}int main()

return 0;

}

SCOI2010 序列操作 線段樹

題面 題解 在考場上打的這道題,出人意料的很快就打完了?直接用線段樹,維護幾個東西 1,lazy標記 表示區間賦值 2,mark標記 表示區間翻轉 3,l1 字首最長連續的1的子段長度 4,l0 字首最長連續的0的子段長度 5,m0 區間內最長的全為0的子段的長度 6,r0 字尾最長連續的0的子段長...

SCOI2010 序列操作 分塊or線段樹

include include define lc k 1 define rc k 1 1 using namespace std const int n 1e5 5 int n,m,a n struct sgts,tr n 2 inline intread while ch 0 ch 9 retu...

1858 Scoi2010 序列操作

1858 scoi2010 序列操作 time limit 10 sec memory limit 64 mb submit 3397 solved 1624 submit status discuss description lxhgww最近收到了乙個01序列,序列裡面包含了n個數,這些數要麼是0...