I am trying to solve FIRESC.
My approach is as follows: ->Max number of fire escape routes = number of connected components in the graph.
->number of ways of selecting the captains = multiplication of size of each of the connected components.
My code is getting WA.
Is this the correct algorithm ?
In case anyone wants to see my code, here is the link: Solution