GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 34 / 0 / 34
Functions: 100.0% 1 / 0 / 1
Branches: 97.1% 34 / 0 / 35

test/cpv/library-checker-datastructure/ordered_set.rbtree.cpp
Line Branch Exec Source
1 // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/ordered_set
2 #include "../../../src/ds/bst/rbt/lib.hpp"
3 #include "../../../src/io/fastin/lib.hpp"
4 #include "../../../src/io/fastout/lib.hpp"
5
6 using namespace tifa_libs;
7 37 int main() {
8 u32 n, q;
9 37 fin_uint >> n >> q;
10 37 rbtree<u32> tr;
11
2/2
✓ Branch 0 taken 8006030 times.
✓ Branch 1 taken 37 times.
8006067 flt_ (u32, i, 0, n, x) {
12 8006030 fin_uint >> x;
13 8006030 tr.insert(x);
14 }
15
2/2
✓ Branch 0 taken 17500021 times.
✓ Branch 1 taken 37 times.
17500058 flt_ (u32, i, 0, q, t, x) {
16 17500021 fin_uint >> t >> x;
17 17500021 auto lb = tr.lower_bound(x);
18
6/7
✓ Branch 0 taken 2982589 times.
✓ Branch 1 taken 2587862 times.
✓ Branch 2 taken 2981723 times.
✓ Branch 3 taken 2982072 times.
✓ Branch 4 taken 2982960 times.
✓ Branch 5 taken 2982815 times.
✗ Branch 6 not taken.
17500021 switch (t) {
19 2982589 case 0:
20
4/4
✓ Branch 0 taken 2884058 times.
✓ Branch 1 taken 98531 times.
✓ Branch 2 taken 733553 times.
✓ Branch 3 taken 2150505 times.
2982589 if (!lb || lb->data != x) tr.insert(x);
21 2982589 break;
22 2587862 case 1:
23
4/4
✓ Branch 0 taken 2397724 times.
✓ Branch 1 taken 190138 times.
✓ Branch 2 taken 737304 times.
✓ Branch 3 taken 1660420 times.
2587862 if (lb && lb->data == x) tr.erase(lb);
24 2587862 break;
25 2981723 case 2:
26
2/2
✓ Branch 1 taken 154578 times.
✓ Branch 2 taken 2827145 times.
2981723 if (tr.size() < x) fout << "-1\n";
27 2827145 else fout << tr.find_by_order(x - 1)->data << '\n';
28 2981723 break;
29
4/4
✓ Branch 1 taken 2512626 times.
✓ Branch 2 taken 469446 times.
✓ Branch 3 taken 859454 times.
✓ Branch 4 taken 1653172 times.
2982072 case 3: fout << tr.order_of_key(x) + (lb ? lb->data == x : false) << '\n'; break;
30 2982960 case 4:
31
2/2
✓ Branch 0 taken 447636 times.
✓ Branch 1 taken 2535324 times.
2982960 if (!lb) lb = rightmost(tr.root);
32
2/2
✓ Branch 0 taken 72592 times.
✓ Branch 1 taken 2910368 times.
2982960 if (!lb) fout << "-1\n";
33
2/2
✓ Branch 0 taken 1232163 times.
✓ Branch 1 taken 1678205 times.
2910368 else if (lb->data <= x) fout << lb->data << '\n';
34
2/2
✓ Branch 1 taken 359667 times.
✓ Branch 2 taken 1318538 times.
1678205 else if (auto pre = tr.prev(lb); !pre) fout << "-1\n";
35 1318538 else fout << pre->data << '\n';
36 2982960 break;
37 2982815 case 5:
38
2/2
✓ Branch 0 taken 498234 times.
✓ Branch 1 taken 2484581 times.
2982815 if (!lb) fout << "-1\n";
39 2484581 else fout << lb->data << '\n';
40 2982815 break;
41 }
42 }
43 37 return 0;
44 37 }
45