| 9 | const std::vector<int> array = {19, 16, 2, 15, 2, 12, 13, 13, 18, 14, 0, 4, 17, 17, 4}; |
| 10 | |
| 11 | void test_generic_sparsetable() { |
| 12 | auto f = [&](int x, int y=0) { return x + y; }; |
| 13 | |
| 14 | #include "sparsetable_definition.h" |
| 15 | #include "sparsetable_generation.h" |
| 16 | |
| 17 | auto sum_query = [&](int L, int R) { |
| 18 | #include "sparsetable_sum_query.h" |
| 19 | return sum; |
| 20 | }; |
| 21 | |
| 22 | for (int L = 0; L < N; L++) { |
| 23 | for (int R = L; R < N; R++) { |
| 24 | int sum = std::accumulate(array.begin() + L, array.begin() + R + 1, 0); |
| 25 | assert(sum == sum_query(L, R)); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | void test_range_sum_sparsetable() { |
| 31 | #include "sparsetable_sum_generation.h" |