Skip to content

Commit 36a8072

Browse files
committed
int trees
1 parent 77d6749 commit 36a8072

File tree

10 files changed

+68
-17
lines changed

10 files changed

+68
-17
lines changed
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
2-
all: IntervalIntervalAssignPlus brute-force gen/genRand
1+
all: IntervalIntervalAssignPlus brute-force gen/genRand train
32

43
IntervalIntervalAssignPlus: IntervalIntervalAssignPlus.cpp
54
./DbgCompile.sh IntervalIntervalAssignPlus
5+
66
brute-force: brute-force.cpp
77
./DbgCompile.sh brute-force
8+
89
gen/genRand: gen/genRand.cpp
910
./DbgCompile.sh gen/genRand
10-
11+
12+
train: train.cpp
13+
./DbgCompile.sh train

DataStructures/IntervalTrees/IntervalIntervalAssignPlus/chk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
gen/genRand
33
100
44
-gena
5-
10000 10000 10000
5+
1000 1000 1000
66
-pat
77
brute-force
88
-tf
99
tests/
10-
-ncs
10+
-tn
11+
test.in
12+
-errs
1113
-tera
1214
-savwa
1315
-gseedt
14-
-gseedt
16+
-sn
17+
train
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Input
2+
n //size of array
3+
m //number of operations
4+
//m rows
5+
ti, ai, bi, ci(ci only if ti == 1) // ti = {0;1}; [ai; bi] interval: [ai; bi] e [1; n]; ci - value
6+
//ti = 1 means set each element in interval [ai; bi] to value ci
7+
8+
Output
9+
for each row with ti = 0 write sum of elements from interval [ai;bi]
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
all: IntervalIntervalPlusMax brute-force gen/genRand train
12

23
IntervalIntervalPlusMax: IntervalIntervalPlusMax.cpp
34
./DbgCompile.sh IntervalIntervalPlusMax
5+
46
brute-force: brute-force.cpp
57
./DbgCompile.sh brute-force
8+
69
gen/genRand: gen/genRand.cpp
710
./DbgCompile.sh gen/genRand
8-
11+
12+
train: train.cpp
13+
./DbgCompile.sh train
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
-gen
22
gen/genRand
3-
10
3+
100
44
-gena
55
1000 1000 1000
66
-pat
77
brute-force
88
-tf
99
tests/
10-
-ncs
10+
-tn
11+
test.in
12+
-errs
1113
-tera
1214
-savwa
13-
-gseedt
15+
-gseedt
16+
-sn
17+
train
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Input
2+
n //size of array
3+
m //number of operations
4+
//m rows
5+
ti, ai, bi, ci(ci only if ti == 1) // ti = {0;1}; [ai; bi] interval: [ai; bi] e [1; n]; ci - value
6+
//ti = 1 means add to each element in interval [ai; bi] value ci
7+
8+
Output
9+
for each row with ti = 0 write max[ai;bi]
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
all: IntervalIntervalPlusPlus brute-force gen/genRand train
12

23
IntervalIntervalPlusPlus: IntervalIntervalPlusPlus.cpp
34
./DbgCompile.sh IntervalIntervalPlusPlus
5+
46
brute-force: brute-force.cpp
57
./DbgCompile.sh brute-force
8+
69
gen/genRand: gen/genRand.cpp
710
./DbgCompile.sh gen/genRand
8-
11+
12+
train: train.cpp
13+
./DbgCompile.sh train

DataStructures/IntervalTrees/IntervalIntervalPlusPlus/brute-force.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ void add(int _beg, int _end, long long _val)
1616

1717
long long query(int _beg, int _end)
1818
{
19-
long long maximum = 0;
19+
long long sum = 0;
2020
for (int i = _beg; i <= _end; i++)
2121
{
22-
maximum += tab[i];
22+
sum += tab[i];
2323
}
24-
return maximum;
24+
return sum;
2525
}
2626

2727
int main()
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
-gen
22
gen/genRand
3-
10
3+
100
44
-gena
55
1000 1000 1000
66
-pat
77
brute-force
88
-tf
99
tests/
10-
-ncs
10+
-tn
11+
test.in
12+
-errs
1113
-tera
1214
-savwa
13-
-gseedt
15+
-gseedt
16+
-sn
17+
train
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Input
2+
n //size of array
3+
m //number of operations
4+
//m rows
5+
ti, ai, bi, ci(ci only if ti == 1) // ti = {0;1}; [ai; bi] interval: [ai; bi] e [1; n]; ci - value
6+
//ti = 1 means add to each element in interval [ai; bi] value ci
7+
8+
Output
9+
for each row with ti = 0 write sum of elements from interval [ai;bi]

0 commit comments

Comments
 (0)