Problems
Articulation points - Timestamps
Articulation points - Timestamps
An undirected graph is given. Run a depth-first search from the given vertex v. Print the timestamps d[v] and up[v] for each vertex v in the increasing order of vertices.
Input
The first line contains the number of vertices n (n ≤ 100) and edges m of an undirected graph. Each of the next m lines contains two vertices a and b - an undirected edge of the graph. The last line contains vertex v.
Output
Run dfs(v). Print the timestamps d[v] and up[v] for each vertex v (v = 1, 2, ..., n). The timestamps for each vertex must be printed on a separate line.
Hint
Use the adjacency matrix to get accepted.
Input example #1
6 8 6 5 6 3 5 3 4 5 3 4 3 2 1 2 1 3 1
Output example #1
1 1 2 1 3 1 4 3 5 3 6 3
Input example #2
7 9 1 2 2 3 1 3 3 4 2 5 4 5 4 6 4 7 6 7 1
Output example #2
1 1 2 1 3 1 4 2 5 2 6 4 7 4