hdu 1166 敵兵布陣

2021-06-11 13:19:07 字數 567 閱讀 2673

基礎線段樹

#include #include int n,m,f[100001];

struct nodee[100000*4];

void build(int a,int b,int c)

e[c].l=a;

e[c].r=b;

int mid=(a+b)/2;

build(a,mid,2*c);

build(mid+1,b,2*c+1);

e[c].sum=e[2*c].sum+e[2*c+1].sum;

}void add(int a,int c,int val)

e[c].sum+=val;

int mid=(e[c].l+e[c].r)/2;

if(a>mid)

add(a,2*c+1,val);

else

add(a,2*c,val);

}int query(int a,int b,int c)

int main()

else}}

return 0;

}

hdu 1166 敵兵布陣

這是一道線段樹里最簡單的一類題目了,單點更新型別!include define lson l m rt 1 define rson m 1 r rt 1 1 const int maxx 55555 int sum maxx 2 void pushup int rt void build int l...

hdu 1166 敵兵布陣

線段樹的模版 沒什麼思想 include include include include include include include include include include include include include define ll long long define vi vec...

HDU 1166 敵兵布陣

description lily 特別喜歡養花,但是由於她的花特別多,所以照料這些花就變得不太容易。她把她的花依次排成一行,每盆花都有乙個美觀值。如果lily把某盆花照料的好的話,這盆花的美觀值就會上公升,如果照料的不好的話,這盆花的美觀值就會下降。有時,lily想知道某段連續的花的美觀值之和是多少...