Challenge yourself to do this project and show me your results!
INPUT: The first line of input contains two integers n and m, where n (1 ≤ n ≤ 5*105) is the number of locations and m (0 ≤ m ≤5 * 105) is the number of streets. Each of the following m lines contains two integers v and w (1 ≤ v < w ≤ n) indicating that there is a two-way street connecting locations v and w. All location pairs in the input are distinct.
OUTPUT: On the first line, output k, the number of dead-end signs installed. On each of the next k lines, output two integers v and w marking that a dead-end sign should be installed at the v-entrance of a street connecting locations v and w. The lines describing dead-end signs must be sorted in ascending order of v-locations, breaking ties in ascending order of w-locations. enter image description here
Aucun commentaire:
Enregistrer un commentaire