Skip to content

Commit

Permalink
Chore: build snippet, index, site
Browse files Browse the repository at this point in the history
  • Loading branch information
theSoberSobber committed Sep 4, 2023
1 parent 101ee3b commit f5dc2f9
Show file tree
Hide file tree
Showing 30 changed files with 156 additions and 46 deletions.
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,27 @@ curl -L "https://raw.githubusercontent.com/theSoberSobber/CP-Snippets/main/snipp
- **[kosaraju](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L933)** : kosaraju
- **[kruskal](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1013)** : kruskal
- **[lambda_function](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1034)** : lambda_function
- **[lca](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1043)** : LCA path satisfying some condition
- **[log](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1104)** : log
- **[matrix](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1135)** : matrix
- **[mint](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1186)** : modular integer
- **[modpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1245)** : modpow
- **[pbds](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1261)** : pbds
- **[pq](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1276)** : pq
- **[prime-related-stuff](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1284)** : implements prime fac, fac list and is_prime in both space optimized and time optimized ways
- **[re-write](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1475)** : a bunch of re and write functions based on template meta programming heklpful in cp.
- **[recur-binsearch](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1497)** : recursive binary search implementation to make intution easier ig
- **[recur-modpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1514)** : recur-modpow
- **[rng](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1530)** : rng
- **[rr-segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1539)** : best segtree
- **[segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1683)** : sextree
- **[seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1797)** : seive
- **[tokenizer](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1815)** : tokenizer that has no use
- **[totient-seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1822)** : totient-seive
- **[totient](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1836)** : totient
- **[trie](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1856)** : trie
- **[troll](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1892)** : troll
- **[two-sat (kosaraju)](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1902)** : two-sat (kosaraju)
- **[variadic](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2039)** : variadic lambdas with 1 and 2 arguments
- **[xor-basis](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2048)** : xor-basis
- **[lca-isAncestor](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1043)** : lca that uses isAncestor instead of level jumping, sets a level upper limit of 25 itself since 2^25 is bigger than any N give anyways
- **[lca](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1094)** : LCA path satisfying some condition
- **[log](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1155)** : log
- **[matrix](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1186)** : matrix
- **[mint](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1237)** : modular integer
- **[modpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1296)** : modpow
- **[pbds](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1312)** : pbds
- **[pq](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1327)** : pq
- **[prime-related-stuff](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1335)** : implements prime fac, fac list and is_prime in both space optimized and time optimized ways
- **[re-write](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1526)** : a bunch of re and write functions based on template meta programming heklpful in cp.
- **[recur-binsearch](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1548)** : recursive binary search implementation to make intution easier ig
- **[recur-modpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1565)** : recur-modpow
- **[rng](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1581)** : rng
- **[rr-segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1590)** : best segtree
- **[segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1734)** : sextree
- **[seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1848)** : seive
- **[tokenizer](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1866)** : tokenizer that has no use
- **[totient-seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1873)** : totient-seive
- **[totient](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1887)** : totient
- **[trie](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1907)** : trie
- **[troll](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1943)** : troll
- **[two-sat (kosaraju)](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1953)** : two-sat (kosaraju)
- **[variadic](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2090)** : variadic lambdas with 1 and 2 arguments
- **[xor-basis](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2099)** : xor-basis
Binary file modified book/codebook-dark.pdf
Binary file not shown.
Binary file modified book/codebook-light.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ curl -L "https://raw.githubusercontent.com/theSoberSobber/CP-Snippets/main/snipp
- **[kosaraju](https://thesobersobber.github.io/CP-Snippets/kosaraju)** : kosaraju
- **[kruskal](https://thesobersobber.github.io/CP-Snippets/kruskal)** : kruskal
- **[lambda_function](https://thesobersobber.github.io/CP-Snippets/lambda_function)** : lambda_function
- **[lca-isAncestor](https://thesobersobber.github.io/CP-Snippets/lca-isAncestor)** : lca that uses isAncestor instead of level jumping, sets a level upper limit of 25 itself since 2^25 is bigger than any N give anyways
- **[lca](https://thesobersobber.github.io/CP-Snippets/lca)** : LCA path satisfying some condition
- **[log](https://thesobersobber.github.io/CP-Snippets/log)** : log
- **[matrix](https://thesobersobber.github.io/CP-Snippets/matrix)** : matrix
Expand Down
56 changes: 56 additions & 0 deletions docs/lca-isAncestor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

## lca-isAncestor

- lca that uses isAncestor instead of level jumping, sets a level upper limit of 25 itself since 2^25 is bigger than any N give anyways
- ```
https://thesobersobber.github.io/CP-Snippets/lca-isAncestor
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1043)

```cpp
void dfs(int node,int parent,vector<vector<pair<int,int>>>&g,vector<vector<int>>&up,vector<vector<ll>>&dp,
vector<int>&tin,vector<int>&tout,vector<int>&depth){
up[node][0]=parent;

for(int i=1;i<25;i++)
up[ node ][i] = up[ up[node][i-1] ][i-1];

tin[node]=timer++;

for(auto &[child,wt] : g[node])
{
if(child==parent)
continue;
depth[child]=depth[node]+1;

dp[child]=dp[node];
dp[child][wt]++;

dfs(child,node,g,up,dp,tin,tout,depth);
}

tout[node]=timer++;
}

bool is_ancestor(int u,int v,vector<int>&tin,vector<int>&tout)
{
return tin[u]<=tin[v] && tout[u]>=tout[v];
}

int LCAquery(int u,int v,vector<vector<int>>&up,vector<int>&tin,vector<int>&tout)
{
if( is_ancestor(u,v,tin,tout) )
return u;
if( is_ancestor(v,u,tin,tout) )
return v;
for(int i=24;i>=0;i--)
{
if (!is_ancestor(up[u][i], v,tin,tout))
{
u = up[u][i];
}
}
return up[u][0];
}

```
2 changes: 1 addition & 1 deletion docs/lca.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/lca
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1043)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1094)

```cpp
constexpr int N = 5; // No. of vertices
Expand Down
2 changes: 1 addition & 1 deletion docs/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/log
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1104)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1155)

```cpp
// Computes x which a ^ x = b mod n.
Expand Down
2 changes: 1 addition & 1 deletion docs/matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/matrix
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1135)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1186)

```cpp
const int MN = 111;
Expand Down
2 changes: 1 addition & 1 deletion docs/mint.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/mint
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1186)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1237)

```cpp
struct mi {
Expand Down
2 changes: 1 addition & 1 deletion docs/modpow.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/modpow
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1245)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1296)

```cpp
ll modpow(ll a, ll b){
Expand Down
1 change: 1 addition & 0 deletions docs/old-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ <h1 id="index--">Index -</h1>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/kosaraju">kosaraju</a></strong> : kosaraju </li>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/kruskal">kruskal</a></strong> : kruskal </li>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/lambda_function">lambda_function</a></strong> : lambda_function </li>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/lca-isAncestor">lca-isAncestor</a></strong> : lca that uses isAncestor instead of level jumping, sets a level upper limit of 25 itself since 2^25 is bigger than any N give anyways </li>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/lca">lca</a></strong> : LCA path satisfying some condition </li>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/log">log</a></strong> : log </li>
<li><strong><a href="https://thesobersobber.github.io/CP-Snippets/matrix">matrix</a></strong> : matrix </li>
Expand Down
2 changes: 1 addition & 1 deletion docs/pbds.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/pbds
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1261)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1312)

```cpp
#include <ext/pb_ds/assoc_container.hpp>
Expand Down
2 changes: 1 addition & 1 deletion docs/pq.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/pq
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1276)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1327)

```cpp
priority_queue<int> pq;
Expand Down
2 changes: 1 addition & 1 deletion docs/prime-related-stuff.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/prime-related-stuff
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1284)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1335)

```cpp
vector<int> smallest_factor;
Expand Down
2 changes: 1 addition & 1 deletion docs/read-write-fn-impl.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/read-write-fn-impl
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1475)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1526)

```cpp
template <class T1, class T2> void re(pair<T1, T2> &p);
Expand Down
2 changes: 1 addition & 1 deletion docs/recur-binsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/recur-binsearch
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1497)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1548)

```cpp
auto check = [&](int mid) {
Expand Down
2 changes: 1 addition & 1 deletion docs/recur-modpow.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/recur-modpow
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1514)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1565)

```cpp
int power(int x, int y){
Expand Down
2 changes: 1 addition & 1 deletion docs/rng.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/rng
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1530)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1581)

```cpp
//random generator
Expand Down
2 changes: 1 addition & 1 deletion docs/rr-segtree.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/rr-segtree
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1539)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1590)

```cpp
int phi[N+1];
Expand Down
2 changes: 1 addition & 1 deletion docs/segtree.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/segtree
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1683)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1734)

```cpp
template<class T, class U>
Expand Down
2 changes: 1 addition & 1 deletion docs/seive.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/seive
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1797)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1848)

```cpp
vector<bool> Prime;
Expand Down
2 changes: 1 addition & 1 deletion docs/tokenizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/tokenizer
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1815)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1866)

```cpp
vec(string) tokenizer(string str,char ch) {std::istringstream var((str)); vec(string) v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;}
Expand Down
2 changes: 1 addition & 1 deletion docs/totient-seive.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/totient-seive
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1822)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1873)

```cpp
for (int i = 1; i < MN; i++)
Expand Down
2 changes: 1 addition & 1 deletion docs/totient.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/totient
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1836)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1887)

```cpp
long long totient(long long n) {
Expand Down
2 changes: 1 addition & 1 deletion docs/trie.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/trie
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1856)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1907)

```cpp
struct Trie{
Expand Down
2 changes: 1 addition & 1 deletion docs/troll.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/troll
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1892)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1943)

```cpp
// Assembly Generator: gcc -S -o temp.s fileName.cpp
Expand Down
2 changes: 1 addition & 1 deletion docs/two-sat (kosaraju).md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/two-sat (kosaraju)
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1902)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1953)

```cpp
/**
Expand Down
2 changes: 1 addition & 1 deletion docs/variadic.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/variadic
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2039)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2090)

```cpp
#define f(u, args...) [&](auto &&u) { return args; }
Expand Down
2 changes: 1 addition & 1 deletion docs/xor-basis.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- ```
https://thesobersobber.github.io/CP-Snippets/xor-basis
```
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2048)
- [github-snip-file](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2099)

```cpp
struct XorBasis{
Expand Down
51 changes: 51 additions & 0 deletions snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,57 @@
],
"description":"lambda_function"
},
"lca-isAncestor": {
"prefix":"lca-isAncestor",
"body": [
"void dfs(int node,int parent,vector<vector<pair<int,int>>>&g,vector<vector<int>>&up,vector<vector<ll>>&dp,",
" vector<int>&tin,vector<int>&tout,vector<int>&depth){",
" up[node][0]=parent;",
" ",
" for(int i=1;i<25;i++)",
" up[ node ][i] = up[ up[node][i-1] ][i-1];",
" ",
" tin[node]=timer++;",
" ",
" for(auto &[child,wt] : g[node])",
" {",
" if(child==parent)",
" continue;",
" depth[child]=depth[node]+1;",
" ",
" dp[child]=dp[node];",
" dp[child][wt]++;",
" ",
" dfs(child,node,g,up,dp,tin,tout,depth);",
" }",
" ",
" tout[node]=timer++;",
"}",
" ",
"bool is_ancestor(int u,int v,vector<int>&tin,vector<int>&tout)",
"{",
" return tin[u]<=tin[v] && tout[u]>=tout[v];",
"}",
" ",
"int LCAquery(int u,int v,vector<vector<int>>&up,vector<int>&tin,vector<int>&tout)",
"{",
" if( is_ancestor(u,v,tin,tout) )",
" return u;",
" if( is_ancestor(v,u,tin,tout) )",
" return v;",
" for(int i=24;i>=0;i--)",
" {",
" if (!is_ancestor(up[u][i], v,tin,tout))",
" {",
" u = up[u][i];",
" }",
" }",
" return up[u][0];",
"}",
""
],
"description":"lca that uses isAncestor instead of level jumping, sets a level upper limit of 25 itself since 2^25 is bigger than any N give anyways"
},
"lca": {
"prefix":"lca",
"body": [
Expand Down

0 comments on commit f5dc2f9

Please sign in to comment.