Hihocoder #1078 modify the interval of the Line Segment tree

Source: Internet
Author: User

Hihocoder #1078 modify the interval of the Line Segment tree

''

Includeinclude

Using namespace std;

Define LL long

Const int maxn = 1000005;
Struct lin {
LL s [maxn <1];
LL m [maxn <1];
Void init (int l, int r, int k ){
If (l = r ){
M [k] = 0;
Scanf ("% d", & s [k]);
Return;
}
Int m = (l + r)> 1;
Init (l, m, k <1 );
Init (m + 1, r, k <1 | 1 );
S [k] = s [k <1] + s [k <1 | 1];
}
Void push_down (int k, int len ){
If (m [k]) {
M [k <1] = m [k <1 | 1] = m [k];
S [k <1] = (len-(len> 1) * m [k];
S [k <1 | 1] = (len> 1) * m [k];
M [k] = 0;
}
}
Int query (int q, int p, int k, int x, int y ){
If (x <= q & p <= y) return s [k];
If (p <x | q> y) return 0;
Push_down (k, p-q + 1 );
Int res = 0;
Int m = (p + q)> 1;
If (x <= m) res + = query (q, m, k <1, x, y );
If (m

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.