Hdu 1698 Just a Hook)

Source: Internet
Author: User

Hdu 1698 Just a Hook)

Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 18411 Accepted Submission (s): 9231


Problem DescriptionIn the game of DotA, Pudge into seconds meat hook is actually the most horrible thing for most of the heroes. the hook is made up of several consecutive metallic sticks which are of the same length.



Now Pudge wants to do some Z stuff · paper "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> paint + paper = "brush: java; "> 11021 5 25 9 3
Sample Output
Case 1: The total value of the hook is 24.


Â Ò Â ° U. Then, you may have £ £ ******************************************************** ü U Ð Â μ ½ μ ײ ã ¾ Í Ð £ ü ± £ ×î ° óf [1]. s ¼ 'çans.


#include
 
  #include
  
   #include
   
    #include
    
     #includeusing namespace std;#define ll __int64#define N 200005struct node{    int l,r;    int s,v,f;  //Çø¼äºÍ¡¢¸ÃÇø¼äµÄµ¥¸öµãµÄÖµ¡¢fΪ²»ÁãÔò¸ÃÇø¼äÓдý¸üÐÂÖµ}f[N*3];void creat(int t,int l,int r){    f[t].l=l;    f[t].r=r;    f[t].v=1;    f[t].f=0;    if(l==r)    {        f[t].s=1;        return ;    }    int tmp=t<<1,mid=(l+r)>>1;    creat(tmp,l,mid);    creat(tmp|1,mid+1,r);    f[t].s=f[tmp].s+f[tmp|1].s;}void update(int t,int l,int r,int v){    int tmp=t<<1,mid=(f[t].l+f[t].r)>>1;    if(f[t].l==l&&f[t].r==r)    {        f[t].v=f[t].f=v;              f[t].s=(r-l+1)*v;        return ;    }    if(f[t].f)      //ÏòϸüР   {        f[tmp].f=f[tmp|1].f=f[t].f;        f[tmp].v=f[tmp|1].v=f[t].f;        f[tmp].s=(f[tmp].r-f[tmp].l+1)*f[t].f;        f[tmp|1].s=(f[tmp|1].r-f[tmp|1].l+1)*f[t].f;        f[t].f=0;    }    if(r<=mid)        update(tmp,l,r,v);    else if(l>mid)        update(tmp|1,l,r,v);    else    {        update(tmp,l,mid,v);        update(tmp|1,mid+1,r,v);    }    f[t].s=f[tmp].s+f[tmp|1].s;      //ÏòÉÏÇóºÍ    f[t].f=0;}int main(){    int T,i,n,q,cnt=1;    scanf("%d",&T);    while(T--)    {        scanf("%d%d",&n,&q);        creat(1,1,n);        while(q--)        {            int l,r,v;            scanf("%d%d%d",&l,&r,&v);            update(1,l,r,v);        }        printf("Case %d: The total value of the hook is %d.\n",cnt++,f[1].s);    }    return 0;}
    
   
  
 





Related Article

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.