• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            線段樹的成段更新與區(qū)間求和,注意更新時及時更新子結點的區(qū)間信息。
            #include<stdio.h>
            #define maxn 100007
            #define L(x) (x<<1)
            #define R(x) ((x<<1)+1)
            struct
            {
                
            long a,b,sum,kind;
            }seg[maxn
            *3];
            long test,n,m;
            void build(long node,long x,long y)
            {
                
            long mid=(x+y)>>1;
                seg[node].a
            =x;seg[node].b=y;
                seg[node].sum
            =seg[node].b-seg[node].a+1;
                seg[node].kind
            =0;
                
            if(x<y)
                {
                   build(L(node),x,mid);
                   build(R(node),mid
            +1,y);
                }
            }
            void insert(long node,long x,long y,long d)
            {
                
            long a=seg[node].a,b=seg[node].b,mid=(a+b)>>1;
                
            if(x<=a&&b<=y)
                {
                   seg[node].kind
            =d;
                   seg[node].sum
            =(seg[node].b-seg[node].a+1)*d;
                }
                
            else
                {
                   
            if(seg[node].kind>0)
                   {
                      seg[L(node)].kind
            =seg[R(node)].kind=seg[node].kind;
                      seg[L(node)].sum
            =(seg[L(node)].b-seg[L(node)].a+1)*seg[L(node)].kind;
                      seg[R(node)].sum
            =(seg[R(node)].b-seg[R(node)].a+1)*seg[R(node)].kind;
                      seg[node].kind
            =0;
                   }
                   
            if(mid>=x)
                     insert(L(node),x,y,d);
                   
            if(mid+1<=y)
                     insert(R(node),x,y,d);
                   seg[node].sum
            =seg[L(node)].sum+seg[R(node)].sum;
                }
            }
            int main()
            {
                scanf(
            "%ld",&test);
                
            for(long k=1;k<=test;k++)
                {
                   scanf(
            "%ld%ld",&n,&m);
                   build(
            1,1,n);
                   
            while(m--)
                   {
                      
            long a,b,d;
                      scanf(
            "%ld%ld%ld",&a,&b,&d);
                      insert(
            1,a,b,d);
                   }
                   printf(
            "Case %ld: The total value of the hook is %ld.\n",k,seg[1].sum);
                }
            return 0;
            }


            posted on 2010-02-24 17:24 lee1r 閱讀(391) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:數(shù)據(jù)結構
            久久青青草原精品影院| 伊人热人久久中文字幕| 久久综合亚洲色HEZYO社区| 久久人人爽爽爽人久久久| 久久久久久午夜成人影院 | 一本一道久久综合狠狠老| 久久久国产精品亚洲一区| 狠狠色丁香久久综合五月| 伊人久久成人成综合网222| 精品久久久久久国产潘金莲| 99久久国产免费福利| 精品无码久久久久久尤物| 午夜精品久久久久久| 国产精品永久久久久久久久久| 欧美精品国产综合久久| 99久久精品国产一区二区| 日韩人妻无码精品久久久不卡| 久久国产热这里只有精品| 久久人人爽爽爽人久久久| 久久精品亚洲AV久久久无码| 久久国产美女免费观看精品| 99久久99久久精品国产片果冻| 久久SE精品一区二区| 亚洲精品第一综合99久久| 久久精品免费大片国产大片| 亚洲国产成人久久精品动漫| 成人综合伊人五月婷久久| 色婷婷综合久久久久中文| 国产成人综合久久精品红| 亚洲国产高清精品线久久| 久久久久久A亚洲欧洲AV冫| 狠狠精品久久久无码中文字幕 | 色老头网站久久网| 国产精品乱码久久久久久软件| 国产日韩欧美久久| 久久久黄片| 亚洲人成网站999久久久综合 | 色8久久人人97超碰香蕉987| 99久久综合狠狠综合久久止| 日本道色综合久久影院| 久久99久久成人免费播放|