CT40697

The ledgers Link Budget Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the mushroom groves of Fungaldeep; Tara weighs the day's ledgers manifests and starts the calculations. 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: 10 37 1 2 1 6 3 10 4 5 6 10 9 10 2 9 5 6 6 7 3 5 1 3 6 8 2 3 8 9 4 8 2 4 1 5 3 8 7 8 2 10 4 9 3 9 1 10 2 5 8 10 5 7 6 9 2 6 1 7 7 10 5 9 7 9 4 6 3 7 3 4 3 6 1 8
Output: 0

Example 2:

Input: 2 1 1 2
Output: 0

Example 3:

Input: 2 1 1 2
Output: 0

Constraints:

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

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