This documentation is automatically generated by online-judge-tools/verification-helper
与えられた木の頂点の部分集合に関して、その頂点を全て含むような最小の木を構築する
query(ws)
: 部分集合 ws
の Aux Tree を破壊的に構築する(必要な頂点が ws
に追加される)clear(ws)
: ws
から伸びている辺を削除する部分集合のサイズを$k$として、$O(k \log k)$
Aux Treeの頂点数は $2k$ 以下になる
#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#define call_from_test
#include "lowestcommonancestor.cpp"
#undef call_from_test
#endif
//BEGIN CUT HERE
struct AuxiliaryTree : LowestCommonAncestor{
using super = LowestCommonAncestor;
vector<int> idx;
vector<vector<int>> T;
AuxiliaryTree(int n):super(n),idx(n),T(n){}
void dfs(int v,int p,int &pos){
idx[v]=pos++;
for(int u:G[v])
if(u!=p) dfs(u,v,pos);
}
void build(int r=0){
super::build(r);
int pos=0;
dfs(r,-1,pos);
}
void add_aux_edge(int u,int v){
T[u].emplace_back(v);
T[v].emplace_back(u);
}
using super::lca, super::dep;
void query(vector<int> &vs){
assert(!vs.empty());
sort(vs.begin(),vs.end(),
[&](int a,int b){return idx[a]<idx[b];});
vs.erase(unique(vs.begin(),vs.end()),vs.end());
int k=vs.size();
stack<int> st;
st.emplace(vs[0]);
for(int i=0;i+1<k;i++){
int w=lca(vs[i],vs[i+1]);
if(w!=vs[i]){
int l=st.top();st.pop();
while(!st.empty() and dep[w]<dep[st.top()]){
add_aux_edge(st.top(),l);
l=st.top();st.pop();
}
if(st.empty() or st.top()!=w){
st.emplace(w);
vs.emplace_back(w);
}
add_aux_edge(w,l);
}
st.emplace(vs[i+1]);
}
while(st.size()>1){
int c=st.top();st.pop();
add_aux_edge(st.top(),c);
}
}
void clear(const vector<int> &ws){
for(int w:ws) T[w].clear();
}
};
//END CUT HERE
#ifndef call_from_test
signed main(){
return 0;
}
#endif
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
bundler.update(path)
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 400, in update
raise BundleErrorAt(path, i + 1, "unable to process #include in #if / #ifdef / #ifndef other than include guards")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: tree/auxiliarytree.cpp: line 6: unable to process #include in #if / #ifdef / #ifndef other than include guards