A Graph Problem

Revision en2, by Not-Afraid, 2019-12-20 12:36:27

Given a simple undirected and connected graph with $$$N$$$ nodes and $$$M$$$ edges. Also two different nodes are given $$$a$$$ and $$$b$$$. We have to answer $$$q$$$ queries. Each query contains an integer $$$v$$$(i.e. a node) from $$$1$$$ to $$$N$$$, we need to answer if we remove node $$$v$$$ and all of it's adjacent edges from the given graph, do nodes $$$a$$$ and $$$b$$$ lies in the same connected component or not? All queries are independent.

Constraints
My partial solution

PS: This problem is not from any contest.

Any hints to solve the above problem are appreciated. Thanks.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Not-Afraid 2019-12-20 12:36:27 65 Tiny change: 'ed. Thanks' -> 'ed. Thanks.'
en1 English Not-Afraid 2019-12-20 12:35:26 733 Initial revision (published)