CT35768

Coral marks Link Budget

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the pearl fisheries of Nacre Bay close for winter, Lysander must finish the marks 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: 10 22 2 6 2 8 4 8 2 5 1 7 1 9 5 7 5 6 6 8 4 5 1 6 9 10 4 7 1 3 5 9 6 7 2 10 2 7 6 9 5 10 2 3 4 10
Output: 0

Example 2:

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

Example 3:

Input: 10000 1966 3017 5526 5682 7346 1288 8215 2483 2512 134 4679 3978 9394 3803 5915 2694 3042 578 4101 1747 6781 3027 5022 2576 9190 1625 1759 975 3087 5845 5877 2769 4980 6181 8870 2240 6688 656 6576 8309 8526 2727 7678 2635 7075 2360 8523 5967 8996 2654 2985 3160 5644 2319 7447 1173 7718 913 6944 1261 2957 2726 4582 4416 4596 1388 4493 352 923 2394 5555 7401 9567 2761 8128 2995 9676 104 9262 8572 9835 80 127 5608 7433 3154 3362 846 3746 6584 7346 628 8065 3657 4479 3113 6367 1405 5247 3371 8303 909 6426 9289 9959 1561 8298 845 3855 6228 8769 981 6564 4142 4708 6353 6710 1652 4857 2343 8175 814 2500 1101 5704 1845 5926 971 6859 5959 6647 2850 8568 1468 4693 3497 4317 48 1759 1379 8174 2260 4564 306 5874 5476 6909 1557 3199 5370 6779 6101 8736 3697 5738 634 9915 3024 8480 4256 5421 147 6108 73…
Output: 8033

Constraints:

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

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