Skip to content

Commit

Permalink
Merge pull request #1140 from hitonanode/issue1138
Browse files Browse the repository at this point in the history
1138 のテストケース追加
  • Loading branch information
maspypy authored Apr 28, 2024
2 parents aba829d + 86ffef0 commit 9de4add
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "random.h"
#include <iostream>
#include <tuple>
#include <vector>
#include "../params.h"
#include "../segtree.hpp"

using namespace std;

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

const long long SMALL_A_ABS_MAX = 100;

int n = gen.uniform<int>(1, N_AND_Q_MAX);
int q = gen.uniform<int>(1, N_AND_Q_MAX);
printf("%d %d\n", n, q);
vector<typename min_max_monoid::value_type> init(n);
for (int i = 0; i < n; i++) {
long long a = gen.uniform<long long>(-SMALL_A_ABS_MAX, SMALL_A_ABS_MAX);
printf("%lld", a);
if (i != n - 1) printf(" ");
init[i] = { a, a };
}
printf("\n");
chmin_chmax_add_min_max_segment_tree segtree(init.begin(), init.end());

for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 3);
int l, r;
tie(l, r) = gen.uniform_pair(0, n);
if (t == 0) {
long long b = gen.uniform<long long>(-SMALL_A_ABS_MAX, SMALL_A_ABS_MAX);
printf("%d %d %d %lld\n", t, l, r, b);
segtree.range_apply(l, r, (typename chmin_chmax_add_monoid::value_type) { b, LLONG_MIN, 0ll });
} else if (t == 1) {
long long b = gen.uniform<long long>(-SMALL_A_ABS_MAX, SMALL_A_ABS_MAX);
printf("%d %d %d %lld\n", t, l, r, b);
segtree.range_apply(l, r, (typename chmin_chmax_add_monoid::value_type) { LLONG_MAX, b, 0ll });
} else if (t == 2) {
auto c = segtree.range_get(0, n);
long long b = gen.uniform<long long>(-SMALL_A_ABS_MAX - c.min, SMALL_A_ABS_MAX - c.max);
segtree.range_apply(l, r, (typename chmin_chmax_add_monoid::value_type) { LLONG_MAX, LLONG_MIN, b });
printf("%d %d %d %lld\n", t, l, r, b);
} else {
printf("%d %d %d\n", t, l, r);
}
}
return 0;
}
8 changes: 7 additions & 1 deletion datastructure/range_chmin_chmax_add_range_sum/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@
"small_08.in": "de54614c264210e47609898635bcfb6440f059a0895a1a078c2d831ef7a732eb",
"small_08.out": "f1270aed58f4d85cde341cfcdb81773760f0e9609bc6764bfc2fca05d8d229c3",
"small_09.in": "9e7e4fe32e402a6a5a928a8ef9531fcebf201f04eac1f222f1aa47d2cf842a70",
"small_09.out": "50bac94959608ff81cfdc25cca9b674fd9fe38f1c8bb3ea50c031339f1d6acdc"
"small_09.out": "50bac94959608ff81cfdc25cca9b674fd9fe38f1c8bb3ea50c031339f1d6acdc",
"small_absolute_values_00.in": "dcc385dff6e3488a4651c94730d3483cf602df333174e99c22018532de717df0",
"small_absolute_values_00.out": "4a2b6788fcf71dd2a368f2bbb11b018b3577227f031dcba2b970eaf7d5ab2fec",
"small_absolute_values_01.in": "7a1ee8ba0d3eb3ad58bcb54dcc65c0bc6f0ce715c8fd7708ae5eefa1217086c9",
"small_absolute_values_01.out": "a3619c7662b614f3b07cca6ab4d753d591a203a78a04a0cc20dc1b002e77f52e",
"small_absolute_values_02.in": "8bf67d5d93dac15a5ad7122be83c2545bf5b86d742e46993cb7b9aeca2f9547d",
"small_absolute_values_02.out": "101c7f11f2b4ca4d23c5a04ef4235110fa06eadfe03f79ddcff6638e305c9855"
}
3 changes: 3 additions & 0 deletions datastructure/range_chmin_chmax_add_range_sum/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/243"
[[tests]]
name = "max_random.cpp"
number = 3
[[tests]]
name = "small_absolute_values.cpp"
number = 3

[[solutions]]
name = "correct_with_assert.cpp"
Expand Down

0 comments on commit 9de4add

Please sign in to comment.