Home I n t e r n e t   C o n t e s t i n t e r n e t

c o n t e s t
C E O I

2 0 0 0


Regulations

Schedule

Organising
Team


Cluj&Romania

Sponsors

Secretariat

Internet Contest

Links


___________
Web design: Vivi

[ The rules | Read the problems | Submit solutions | Results | Downloads ]


[ Problem 1 | Problem 2 | Problem 3 ]

Problem 2 : Roads

The Romanian Ministry of Transport decides to upgrade the Romanian roads. Each road is bidirectional and directly connects two towns. No two towns are directly connected by more than one road. The existing road network ensures direct or indirect links between any two towns in Romania.
However, upgrading the roads implies closing, in turn, each road and performing the necessary repairs. During these operations, it is necessary to preserve the road network connectivity. In order to do so, the Minister decides that new roads should be built, so that no matter which single road is closed at any given moment (exactly one road at a time), the traffic between any given pair of towns should still be possible. Of course, the number of these newly added roads should be minimized. Furthermore, no new road may directly connect two directly connected towns.

Task
Write a program that determines the minimum number of the additional roads to be built and the pairs of towns to be connected with them. If there are several optimal solutions, only one is required.

Input
File name: ROADS.IN
Line 1: N M
  • two integers, separated by a blank, representing respectively the number of the towns and the number of the roads. The towns are labelled from 1 to N.
    Lines 2..M+1: T1 T2
  • two integers separated by a blank, representing the two towns connected by a road.

    Output
    File name: ROADS.OUT
    Line 1: K
  • an integer, representing the minimum number of additional roads.
    Lines 2..K+1: C1 C2
  • two integers separated by a blank, representing a pair of towns (cities) to be connected by a road.
    Remark
  • the order of town pairs in the output file is irrelevant.

    Limits
  • 3 <= N <= 2500
  • 2 <= M <= 20000
    Example
    ROADS.IN 		ROADS.OUT
    4 3			2
    1 2			1 4
    2 3			1 3
    2 4
    
  •