summaryrefslogtreecommitdiff
path: root/datastructures/test/sparseTable.cpp
blob: ed4d61f68d3389db0307e55b2e349fcb550eec19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "../sparseTable.cpp"

void test(int n) {
	vector<ll> values(n);
	for (ll &x: values) x = util::randint();
	SparseTable st;
	st.init(values);
	for (int i = 0; i < n; i++) {
		int l = util::randint(n);
		int r = util::randint(n);
		if (l > r) swap(l, r);
		r++;
		assert(
			values[st.queryIdempotent(l, r)]
			==
			*min_element(values.begin()+l, values.begin()+r)
		);
	}
}

int main() {
	test(1000);
	test(1);
}