| 85 | segment_tree st; |
| 86 | |
| 87 | lca_tree(int n, int root, vi *children) { |
| 88 | label = new int[n]; |
| 89 | orig = new int[n]; |
| 90 | start = new int[n]; |
| 91 | memset(label, -1, n << 2); |
| 92 | int at = 0; |
| 93 | queue<int> Q; |
| 94 | Q.push(root); |
| 95 | label[root] = at++; |
| 96 | while (!Q.empty()) { |
| 97 | int cur = Q.front(); |
| 98 | orig[label[cur]] = cur; |
| 99 | Q.pop(); |
| 100 | for (int i = 0; i < size(children[cur]); i++) { |
| 101 | int nxt = children[cur][i]; |
| 102 | if (label[nxt] == -1) { |
| 103 | label[nxt] = at++; |
| 104 | Q.push(nxt); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | seq(children, root); |
| 110 | st = segment_tree(s); |
| 111 | } |
| 112 | |
| 113 | void seq(vi *c, int r) { |
| 114 | start[label[r]] = size(s); |
nothing calls this directly
no test coverage detected