title | documentation_of |
---|---|
LCA-based auxiliary tree / virtual tree, online ("虚树") |
./auxiliary_tree.hpp |
予め根付き木
-
に 1 頂点追加 -
から 1 頂点削除 -
の要素の組の最小共通祖先 (lowest common ancestor, LCA) 全てを頂点とし、もとの木と子孫関係を保った根付き木 を考える. に関して以下に答える: -
の頂点 が に含まれるかどうか -
の頂点 が に含まれるかどうか - 特に
における の親 - 特に
における の子の集合
- 特に
-
の根となる頂点
-
現実装では
vector<vector<int>> to(N); // edges of tree
int root = 0;
auxiliary_tree at(to, root);
int v;
at.activate(v); // Add v to S
at.deactivate(v); // Remove v from S
int r = at.auxiliary_root(); // Root of T' (if exists) or -1
int par = at.get_parent(v); // Parent of v in T' (if exists) or -1
vector<int> children = at.get_children(v); // Children of v in T'
bool b1 = at.is_active(v); // v in S?
bool b2 = at.is_semiactive(v); // v in T'?