MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / lca_tree

Method lca_tree

code/graph/tarjan_olca.test.cpp:87–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 4

segment_treeClass · 0.85
pushMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected