Created
May 13, 2020 10:13
-
-
Save joonas-yoon/2c3b5c01d63baedd25baf40a8f58402a to your computer and use it in GitHub Desktop.
using Eulerian path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MAX_V 100001 | |
int id = 0; | |
int L[MAX_V], R[MAX_V]; // [L, R] | |
vector<int> adj[MAX_V]; | |
int dfs(int cur) { | |
int i = ++id, cnt = 0; | |
L[cur] = i; | |
for (auto& nxt : adj[cur]) { | |
cnt += 1 + dfs(nxt); | |
} | |
R[cur] = i + cnt; | |
return cnt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment