Skip to content

Commit 90480fa

Browse files
committed
update tests
1 parent b82e364 commit 90480fa

File tree

6 files changed

+73
-250
lines changed

6 files changed

+73
-250
lines changed

tests/library_checker_aizu_tests/data_structures/dsu_restorable.test.cpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp

Lines changed: 0 additions & 127 deletions
This file was deleted.

tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp

Lines changed: 0 additions & 77 deletions
This file was deleted.

tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"https://judge.yosupo.jp/problem/two_edge_connected_components"
33
#include "../template.hpp"
44
#include "../../../library/graphs/uncommon/bridge_tree.hpp"
5-
#include "../../../library/dsu/dsu_restorable.hpp"
5+
#include "../../../library/dsu/dsu.hpp"
66
int main() {
77
cin.tie(0)->sync_with_stdio(0);
88
int n, m;
@@ -33,7 +33,7 @@ int main() {
3333
accumulate(begin(is_br), end(is_br), 0);
3434
assert(sum_deg % 2 == 0 && sum_deg / 2 == cnt_bridges);
3535
}
36-
dsu_restorable dsu(n);
36+
DSU dsu(n);
3737
int num_sets_dsu = n;
3838
for (int i = 0; i < m; i++) {
3939
if (!is_br[i]) {
@@ -45,12 +45,11 @@ int main() {
4545
for (int i = 0; i < m; i++) {
4646
if (is_br[i]) {
4747
auto [u, v] = edges[i];
48-
bool same_set = dsu.same_set(u, v);
49-
assert(!same_set);
48+
assert(dsu.f(u) != dsu.f(v));
5049
}
5150
}
5251
for (int i = 0; i < n; i++) {
53-
int par_of_cc = dsu.find(i);
52+
int par_of_cc = dsu.f(i);
5453
assert(br_id[i] == br_id[par_of_cc]);
5554
}
5655
for (int i = 0; i < m; i++) {

tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A"
33
#include "../template.hpp"
44
#include "../../../library/contest/random.hpp"
5-
#include "../../../library/dsu/dsu_restorable.hpp"
5+
#include "../../../library/dsu/dsu.hpp"
66
int main() {
77
cin.tie(0)->sync_with_stdio(0);
88
for (int n = 1; n < 100; n++) {
9-
dsu_restorable dsu(n);
9+
DSU dsu(n);
1010
vector<vector<int>> adj(n);
1111
vector<pair<int, int>> edge_st;
1212
for (int q = 0; q < 100; q++) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#define PROBLEM \
2+
"https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A"
3+
#include "../template.hpp"
4+
#include "../../../library/data_structures_[l,r)/seg_tree_midpoint.hpp"
5+
int main() {
6+
cin.tie(0)->sync_with_stdio(0);
7+
for (int n = 1; n < 5000; n++) {
8+
auto dfs = [&](auto&& self, int tl, int tr,
9+
int v) -> void {
10+
assert((v >= n) == ((tr - tl) == 1));
11+
if (v >= n) { // leaf node
12+
const int depth_leaf = __lg(v),
13+
max_depth = __lg(2 * n - 1);
14+
if (tl == 0) { // left-most leaf
15+
assert(v == (1 << max_depth));
16+
assert(depth_leaf == max_depth);
17+
}
18+
assert(n <= v && v < 2 * n);
19+
assert(depth_leaf == max_depth ||
20+
depth_leaf == max_depth - 1);
21+
if ((n & (n - 1)) == 0)
22+
assert(depth_leaf == max_depth);
23+
} else {
24+
assert(1 <= v && v < n);
25+
if (((tr - tl) & (tr - tl - 1)) == 0)
26+
assert(split(tl, tr) == (tl + tr) / 2);
27+
{
28+
int pow_2 = 1 << __lg(tr - tl);
29+
if (tl + pow_2 < tr - pow_2 / 2) {
30+
assert(pow_2 != tr - tl);
31+
assert(pow_2 / 2 < tr - tl - pow_2 &&
32+
tr - tl - pow_2 < pow_2);
33+
assert(pow_2 <= 2 * (tr - tl - pow_2) - 1 &&
34+
2 * (tr - tl - pow_2) - 1 < 2 * pow_2 - 1);
35+
assert(__lg(pow_2) ==
36+
__lg(2 * ((tr - tl) - pow_2) - 1) &&
37+
__lg(pow_2) == __lg(2 * pow_2 - 1));
38+
} else if (pow_2 < tr - tl) {
39+
assert(pow_2 / 2 < tr - tl - pow_2 / 2 &&
40+
tr - tl - pow_2 / 2 <= pow_2);
41+
assert(
42+
pow_2 <= 2 * ((tr - tl) - pow_2 / 2) - 1 &&
43+
2 * ((tr - tl) - pow_2 / 2) - 1 <=
44+
2 * pow_2 - 1);
45+
assert(__lg(2 * (tr - tl - pow_2 / 2) - 1) ==
46+
__lg(2 * pow_2 - 1));
47+
assert(__lg(2 * ((tr - tl) - pow_2 / 2) - 1) ==
48+
__lg(pow_2));
49+
assert(__lg(pow_2) ==
50+
1 + __lg(2 * (pow_2 / 2) - 1));
51+
}
52+
}
53+
int tm = split(tl, tr);
54+
// in particular, this tests that split works with
55+
// negatives
56+
assert(split(tl - 1234, tr - 1234) == tm - 1234);
57+
assert(split(tl - 1, tr - 1) == tm - 1);
58+
assert(split(tl + 50, tr + 50) == tm + 50);
59+
self(self, tl, tm, 2 * v);
60+
self(self, tm, tr, 2 * v + 1);
61+
}
62+
};
63+
dfs(dfs, 0, n, 1);
64+
}
65+
cout << "Hello World\n";
66+
return 0;
67+
}

0 commit comments

Comments
 (0)