| 76 | }; |
| 77 | |
| 78 | void test() { |
| 79 | /* Field testing: SPOJ LCA, SPOJ QTREE, TOJ 2241, Live Archive 2045, Live Archive 6140, UVa 10938, IPSC 2009 L */ |
| 80 | |
| 81 | int ts = 100, |
| 82 | maxn = 1000, |
| 83 | maxq = 1000, |
| 84 | minc = -1000, |
| 85 | maxc = 1000; |
| 86 | |
| 87 | // ts = 100000; |
| 88 | // maxn = 4; |
| 89 | // minc = 1; |
| 90 | // maxc = 4; |
| 91 | // maxq = 5; |
| 92 | |
| 93 | for (int t = 0; t < ts; t++) |
| 94 | { |
| 95 | // printf("%d\n", t); |
| 96 | |
| 97 | int n = randint(1, maxn), |
| 98 | qs = maxq; |
| 99 | |
| 100 | HLD hld1(n); |
| 101 | HLD_naive hld2(n); |
| 102 | |
| 103 | union_find uf(n); |
| 104 | vii edges; |
| 105 | vvi adj(n); |
| 106 | for (int i = 0; i < n - 1; i++) |
| 107 | { |
| 108 | while (true) |
| 109 | { |
| 110 | int a = randint(0, n - 1), |
| 111 | b = randint(0, n - 1); |
| 112 | |
| 113 | if (uf.find(a) == uf.find(b)) |
| 114 | continue; |
| 115 | |
| 116 | uf.unite(a, b); |
| 117 | // hld1.add_edge(a, b); |
| 118 | // hld2.add_edge(a, b); |
| 119 | edges.push_back(ii(a, b)); |
| 120 | edges.push_back(ii(b, a)); |
| 121 | adj[a].push_back(b); |
| 122 | adj[b].push_back(a); |
| 123 | hld1.add_edge(a,b); |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | vector<int> parent(n, -1); |
| 129 | |
| 130 | stack<int> S; |
| 131 | vector<bool> visited(n, false); |
| 132 | int root = randint(0, n - 1); |
| 133 | visited[root] = true; |
| 134 | S.push(root); |
| 135 |
nothing calls this directly
no test coverage detected