IITKESO207PA6Q2 - Metro City
A country has n islands numbered 0 to n-1. Some of these islands are connected by bridges. You are given that all bridges are two-way. Moreover, the initial network is such that it is possible to go from any island to any other island (via bridges). However, the country could face trouble when the water level rises and islands are submerged. When an island is submerged, all bridges incident on that island are shutdown. We call an island z bad if submerging that bridge disconnects the country, i.e., there exist two islands x, y such that we cannot go from x to y if z is submerged (x, y are distinct from z). You are required to find all the bad islands in the city.
Input
First line of input consists of 2 space separated integers n and m. n denotes the number of islands and m denotes the total number of bridges initially. m lines follow.
Each of the m lines denotes the two endpoints of a bi-directional bridge.
Output
Output a list of the bad islands in sorted order.
Example
Input: 5 5
2 0
3 1
2 3
4 3
1 4 Output: 2
3
Added by: | ESO207 IITK |
Date: | 2018-04-09 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |