Given an undirected sparse graph G and a list of queries (each query consisting of two nodes), how to determine if there exists exactly one simple path between them (for each query) ? I have a (trivial) solution based on a breadth-first search (for each query the complexity would be O(V+E)) but is there a more efficient way to answer the queries?
You don't have to find the actual simple path, just answer each query with a True/False answer.
This question was asked as part of the Latin American regional competition of the 2011 ACM International Collegiate Programming Contest.