One-Sided Love
InterviewTime limit2sMemory limit1024 MB
For each node x other than 1, decide whether two paths from node 1 to x share no node besides 1 and x, and output a binary string.
Problem
Today too, the bell rings to end school. Until half a year ago, I waited for this hour with my nose buried in comic books. But at some point, I started to feel regret when this time came. Does she still think I am reading comics? Maybe the warm evening glow on the way home dazzled my eyes, because I wandered off the road. Now I follow behind her in secret.
Problem
You are given an undirected graph. The school is node , and her house is at some node other than . To avoid being noticed, you must not visit any node she has visited before she reaches her house. For each node, determine whether it is possible to avoid being noticed. That is, find all nodes , except node , that satisfy the following condition.
- Among the paths from node to node , there exist two paths in which no node other than and is shared. The two paths may be identical.
Input
The first line contains the number of nodes and the number of edges , separated by a space. (; )
Each of the next lines contains and , separated by a space. This means nodes and are connected in both directions. (; )
Output
The first line prints a binary string of digits that marks the nodes satisfying the condition. The -th bit from the left is if node satisfies the condition, and otherwise. Node is always .