Delete Two Vertices Again
Time limit6sMemory limit512 MB
For each edge of a connected graph, decide whether deleting both of its endpoints leaves the remaining graph connected, and print a binary string.
Problem
Several years ago, the same author proposed the following problem for a school competition: delete two adjacent vertices from a given connected undirected graph with min-degree at least so that the graph stays connected. That problem is too simple for a student competition in 2020, so here is a harder version.
You are given a connected undirected graph with at least vertices. It has no self-loops and no multiple edges. For each edge, determine whether deleting both of its endpoints keeps the graph connected.
The graph may contain vertices of degree , but it has no vertices of degree , because it is connected and has at least vertices.
Input
The first line contains two integers and (, ), the number of vertices and the number of edges. The -th of the following lines contains two space-separated integers and , the endpoints of the -th edge (, ). The graph is connected and has no multiple edges.
Output
Print a binary string of length . The -th character is "0" if deleting the endpoints of the -th edge disconnects the graph, and "1" otherwise.
Hint
Note that both endpoints of the edge are deleted, not only the edge itself. So this task is different from finding bridges.
For example, in the sample, edge - is not a bridge, but deleting vertices and disconnects the graph. The remaining graph consists of two isolated vertices, and . On the other hand, edge - is a bridge, but deleting vertices and leaves the graph connected. The remaining vertices and are joined by edge -.