HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC - 2013-2014 > problem:


14-04-50. 50697 - Base Stations

IMPC - 2013-2014

Start: Mar.16.2013 at 12:00:00 PM
Finish: Mar.16.2013 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (2)

Contest problems

• 14-03-60. 50382 - Parkside's Other ...
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-80. 50675 - Kruja Boys
• 14-03-90. 50717 - Hurdle Jumping
• 14-04-20. 50493 - n-digit kth Prime ...
• 14-04-30. 50669 - Area of an Irregu...
• 14-04-40. 50712 - Moon algebra
• 14-04-50. 50697 - Base Stations
• 14-05-10. 50723 - Tribonacci
• 14-05-20. 50677 - The Cottage
• 14-05-20. 50413 - Valid Permutations
• 14-05-30. 50688 - Epoka Furgon
• 14-05-30. 50706 - The most crowd...
• 14-05-40. 50689 - The biggest build...
• 14-05-50. 50414 - Traffic
• 14-05-50. 50421 - Repairing road s...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Osman Ay.

Base Stations

Question: A GSM Company has recently built new base stations to extend his coverage area. The fiber optic communication cables are used to connect any two base stations. The company hired you to be sure that all the base stations are connected each other directly or via some other base stations. The company has the list of the directly connected base stations. You should make a program that prints number of the additional connections needed to fulfill the company's demand.

Input specification
The first line of the input contains two integers N (1 ≤ N ≤ 1000) and M (1 ≤ M ≤ 100000). N is the number of the base stations and M is the number of the connections. The base stations are numbered from 1 to N. Each of the following M lines represents a unique connection with a pair of integer: x and y (1 ≤ x, y ≤ N) where, x and y denotes the station numbers. The stations are numbered from 1 to N.

Output specification
The output contains a single integer that is number of the additional connections. If all the base stations are already connected each other, print 0.

 Sample Input   
 7 8
 1 5
 1 4
 3 7
 2 4
 2 6
 2 5
 5 6
 1 6
 Sample Output   
 1


Для отправки решений необходимо выполнить вход.

www.contester.ru