#K5091. Taco: Find Unreachable Zones

    ID: 28969 Type: Default 1000ms 256MiB

Taco: Find Unreachable Zones

Taco: Find Unreachable Zones

In this problem, you are given a city with Z delivery zones numbered from 1 to Z, and R roads connecting pairs of these zones. The roads are bidirectional, meaning that if there is a road between zone u and zone v, it can be traversed in both directions.

\

A driver starts at the central hub located in zone 1 and needs to determine which zones are unreachable from the hub. This is a classic graph connectivity problem where zones represent nodes and roads represent edges in an undirected graph. You can solve the problem using a breadth-first search (BFS) starting from zone 1.

\

The input is provided via standard input (stdin) and the output must be printed to standard output (stdout). If all zones are accessible from zone 1, print All Zones Accessible; otherwise, print the list of unreachable zones in ascending order, separated by a single space.

\

Mathematical Note: If we denote the graph as \(G = (V, E)\) with \(V = \{1, 2, \ldots, Z\}\) and each road as an edge \((u, v) \in E\), the task is to find the set of nodes \(U = \{v \in V : v \not\in R(1)\}\) where \(R(1)\) is the set of nodes reachable from node 1 via BFS.

inputFormat

The first line of input contains two integers Z and R where:

\
    \
  • Z (1 ≤ Z ≤ 200000) represents the number of zones.
  • \
  • R (0 ≤ R ≤ 200000) represents the number of bidirectional roads.
  • \
\

The next R lines each contain two integers u and v, indicating a road connecting zone u and zone v.

outputFormat

If all zones are reachable from zone 1, output All Zones Accessible (without quotes). Otherwise, output the unreachable zones in ascending order as a single line of space-separated integers.

## sample
5 4
1 2
2 3
3 4
4 5
All Zones Accessible