CT36920

The registers at Buzzwell

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the honey farms of Buzzwell close for winter, Vera must finish the registers ledger - one figure at a time. 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: 2 0
Output: 1

Example 3:

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

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.