CT37403

Squire's Link Budget Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the canyon post of Redrock, Squire studies rows of signals entries. One clean number will settle the guild's oldest argument. 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 1 1 2
Output: 0

Example 2:

Input: 2 0
Output: 1

Example 3:

Input: 10 23 1 4 5 9 3 9 5 6 1 3 4 6 3 7 6 9 4 7 7 9 1 8 3 8 5 10 1 10 8 9 2 9 6 10 2 4 6 7 1 7 2 3 4 10 5 7
Output: 0

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Squire's Link Budget Ledger - MEDIUM Coding Problem | CodeTikki