[Offer收割]编程练习赛40 register

Ended

Participants:189

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-17 14:21:13

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
int f[404000],lz[404000];
using namespace std;
int find(int a,int b,int l,int r,int root){
    if (a<=l&&r<=b) {
    //    printf("%d %d %d\n",l,r,lz[root]);
        return lz[root];
    }
    int mid=(l+r)>>1,t1=0,t2=0,t=0;
    if (b>=l&&a<=r) t=f[root];
    if (a<=mid) t1=find(a,b,l,mid,root<<1);
    if (b>mid) t2=find(a,b,mid+1,r,root<<1|1);
    t = max(t,max(t1,t2));
   // printf("%d %d %d %d %d %d\n",a,l,r,b,t,f[root]);
    return t;
}
void cl(int a,int b,int l,int r,int root,int t){
    if (a<=l&&r<=b) {
     //   printf("````%d %d %d %d\n",l,r,root,t);
        f[root]=t;
        lz[root]=t;
        return;
    }
    int mid=(l+r)>>1;
    if (a<=mid) cl(a,b,l,mid,root<<1,t);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX