CT55486

Wistful signals Link Budget

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The store warden Admiral has been asked to prepare the winter inventory. On the desk lies a long table of signals readings. 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 13 7 9 1 5 4 9 6 10 2 10 1 6 3 5 5 6 3 7 3 9 3 8 6 8 3 4
Output: 0

Example 2:

Input: 2 0
Output: 1

Example 3:

Input: 10000 3884 3463 6903 6267 8749 66 6822 7969 9445 56 9377 1082 8997 1238 4559 401 1903 857 8373 7392 9160 1606 4657 1803 2181 6865 9133 1146 2324 4262 9634 3263 4335 5177 7769 1288 5874 2282 5788 2768 3153 5954 7114 8649 9128 8802 8854 6093 6417 6374 6935 6110 7038 377 6259 1688 3816 370 9561 6604 9899 3191 6700 2419 7010 466 7118 1059 3293 5093 7123 1816 7704 4807 8466 3573 4169 1428 7763 5021 9091 3748 8709 3939 9044 2402 9697 3614 5075 2077 4138 7634 8785 213 2108 791 9071 3413 9685 7663 9502 548 2083 7303 8627 2324 9680 4767 8899 5936 7496 6955 9092 3063 6817 5943 8960 4966 9392 1094 2604 2167 2200 6521 6705 6651 9324 4927 8098 7120 9136 915 9348 4381 5283 4189 5521 7570 8706 2341 3802 2019 3967 3853 4632 1284 2095 644 1001 3173 5526 8748 9851 2181 6526 3376 7045 2243 4059 1172 5276 174…
Output: 6116

Constraints:

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

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