CT39037

The Solar Link Budget

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the marble forum of Argentium. Herald spreads the ledgers records across the table and picks up a sharp pencil. Task: n isolated nodes are joined by m edges (some may be redundant). Print the minimum number of additional edges needed to make the graph connected. Input format: First line: n and m. Next m lines: u v. Output format: Print the number of extra edges needed. Constraints: 1 <= n <= 4000; 0 <= m <= 4000.

Example 1:

Input: 2 0
Output: 1

Example 2:

Input: 10000 62 248 2548 1588 9640 5163 5245 6947 9645 3111 4807 6168 7592 1765 7311 3044 3243 7890 8422 4445 9225 492 9499 3864 4310 107 4491 1003 2372 8515 9205 3063 3513 4810 5684 1305 1739 1747 2950 2115 5628 4562 7382 1572 3169 900 9423 384 6600 4563 7881 1121 4885 7409 8002 1062 9564 1537 2553 1622 4477 6707 9904 3357 7113 1592 6527 2382 5042 5478 7663 1480 7495 9215 9287 1231 4974 2231 9412 1778 8566 100 9332 407 6483 5548 7131 2420 5315 526 6718 661 5852 763 3500 4289 8138 1887 7453 1537 4067 1867 4674 2948 7272 3116 5654 2012 6763 812 5265 1505 2459 7052 7184 2435 2947 1634 2091 4822 6279 7252 9636 562 8492
Output: 9937

Example 3:

Input: 2 0
Output: 1

Constraints:

1 <= n <= 4000; 0 <= m <= 4000.

Loading...
Test Cases:No test cases
No test cases available.
The Solar Link Budget - MEDIUM Coding Problem | CodeTikki