diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 01:24:14 +0100 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 01:24:14 +0100 |
| commit | 98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch) | |
| tree | 5113d5cc24d1ad5f93810b6442ce584a36950dc8 /graph/virtualTree.cpp | |
| parent | ad3856a6b766087df0036de0b556f4700a6498c9 (diff) | |
| parent | 8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff) | |
mzuenni tests
Diffstat (limited to 'graph/virtualTree.cpp')
| -rw-r--r-- | graph/virtualTree.cpp | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/graph/virtualTree.cpp b/graph/virtualTree.cpp deleted file mode 100644 index 2fcea80..0000000 --- a/graph/virtualTree.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// needs dfs in- and out- time and lca function -vector<int> in, out; - -void virtualTree(vector<int> ind) { // indices of used nodes - sort(all(ind), [&](int x, int y) {return in[x] < in[y];}); - for (int i=0; i<sz(a)-1; i++) { - ind.push_back(lca(ind[i], ind[i+1])); - } - sort(all(ind), [&](int x, int y) {return in[x] < in[y];}); - ind.erase(unique(all(ind)), ind.end()); - - int n = ind.size(); - vector<vector<int>> tree(n); - vector<int> st = {0}; - for (int i=1; i<n; i++) { - while (in[ind[i]] >= out[ind[st.back()]]) st.pop_back(); - tree[st.back()].push_back(i); - st.push(i); - } - // virtual directed tree with n nodes, original indices in ind - // weights can be calculated, e.g. with binary lifting -} |
