File tree 1 file changed +6
-15
lines changed
1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 2
2
struct Node
3
3
{
4
4
public:
5
- ll count;
6
5
ll num;
7
-
8
- Node (ll a,ll b ) : num(a), count(b ) {}
9
- Node () : num(0 ), count( 1 ) {}
6
+
7
+ Node (ll a) : num(a) {}
8
+ Node () : num(0 ) {}
10
9
11
10
void add (ll val)
12
11
{
@@ -25,15 +24,7 @@ struct SegmentTree
25
24
26
25
Node combine (Node a, Node b)
27
26
{
28
- if (a.num == b.num )
29
- {
30
- return Node (a.num ,a.count +b.count );
31
- }
32
- if (a.num > b.num )
33
- {
34
- return a;
35
- }
36
- return b;
27
+ return Node (a.num +b.num );
37
28
}
38
29
39
30
void propogate (ll v, ll start, ll end)
@@ -43,7 +34,7 @@ struct SegmentTree
43
34
lazy[2 *v] += lazy[v];
44
35
lazy[2 *v+1 ] += lazy[v];
45
36
}
46
- segment[v].add (lazy[v]);
37
+ segment[v].add (lazy[v]*(end - start + 1 ) );
47
38
lazy[v] = 0 ;
48
39
}
49
40
@@ -84,7 +75,7 @@ struct SegmentTree
84
75
propogate (v,start,end);
85
76
if (rangeY < start or end < rangeX)
86
77
{
87
- return Node (- 1 , 0 );
78
+ return Node ();
88
79
}
89
80
if (rangeX <= start and end <= rangeY)
90
81
{
You can’t perform that action at this time.
0 commit comments