Ad
  • Custom User Avatar

    yes some tests are random.

  • Custom User Avatar

    In your example city you can go from p2 to p0 but you cannot go from p2 to p0. To make the problem simpler, I prefered to avoid such cases as explained in the description even if there are algorithm to compute connected components in directed graphs.

    Maybe it could be another kata ?

  • Custom User Avatar

    Given your question the problem was probably not correctly explained.
    A district consists of all the places which are reachable, but not necessarily directly reachable. Since p0, p1 and p2 are reachable they are all in the same district. However, there is no street from p3 to the other places, so it is in another district.

    To solve this problem, the order from which you start exploring does not matter.

    I changed the description to make the problem more clear, I hope it will help.