CT38799

Jasper registers Link Budget

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the old quarter of Brasshaven pays by the answer, and Wynne intends to earn it. First: the full register of registers. 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 39 2 3 2 5 3 5 1 9 1 8 5 7 9 10 8 10 1 2 6 7 1 7 6 10 5 9 2 10 3 4 2 7 1 5 6 9 8 9 4 7 2 9 7 10 5 10 4 6 5 6 1 6 2 4 1 3 3 6 5 8 7 8 3 7 2 8 4 10 6 8 3 9 3 8 1 4 3 10
Output: 0

Example 2:

Input: 100 413 7 53 12 38 22 90 28 73 59 99 71 74 57 90 84 98 8 31 31 38 30 64 63 70 66 75 40 60 25 81 43 93 24 95 51 96 25 37 2 71 18 82 28 61 47 66 44 92 1 24 69 89 41 98 15 36 65 66 6 45 71 81 36 65 2 31 8 94 1 61 23 37 28 96 6 46 66 78 42 83 70 84 38 93 8 74 3 40 14 37 50 85 61 67 37 71 13 94 39 90 12 67 30 67 56 64 67 75 25 100 78 94 40 86 51 75 20 28 21 61 20 81 37 41 26 100 4 31 64 66 45 67 6 48 50 73 2 23 41 94 14 87 53 95 27 89 54 78 19 45 10 55 89 100 1 51 40 77 57 93 63 66 10 65 16 67 6 14 26 65 4 35 20 91 14 77 16 77 27 75 34 83 36 88 2 68 57 88 20 31 14 39 18 92 24 63 80 86 48 54 12 56 29 98 27 100 75 86 86 100 27 76 18 60 20 92 32 78 36 51 9 18 16 78 8 13 7 82 55 98 84 97 11 49 91 92 46 58 41 81 55 92 31 85 31 75 8 63 45 55 4 14 24 100 91 95 1 39 2 48 38 64 27 63 10 93 25 98 1 28 10…
Output: 0

Example 3:

Input: 2 0
Output: 1

Constraints:

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

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