Edges on a path
Practice
4.4 (23 votes)
Algorithms
Articulation points and bridges
Bridges
C++
Graphs
Problem
76% Success 3842 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given a connected graph with n nodes and m edges, where m <= n.You are also given two nodes a and b of the graph.
You need to find the number of edges which are present in all paths between a and b.
CONSTRAINTS:
1 <= N <= 105
N-1 <= M <= min(105,N)
1 <= a,b <= N possibly a = b.
INPUT FORMAT :
The First line contains two space separated integers N and M, the number of nodes and edges respectively.
The second line contains two space separated integers a and b.
Then m lines follow, the i-th line contains two integers xi and yi (1≤xi,yi≤n, xi≠yi) --- the endpoints of the i-th edge.
OUTPUT FORMAT :
The output should contain a single number which is the number of edges present in all paths between a and b.
Submissions
Please login to view your submissions
Similar Problems
Points:50
2 votes
Tags:
AlgorithmsApprovedGraphsMedium
Points:50
13 votes
Tags:
Data StructuresGraphsMediumTrees
Editorial