CT48572

The Separate Camps of Horselord Plains

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the steppe camp of Horselord Plains pays by the answer, and Cyrus intends to earn it. First: the full register of tunnels. Task: An undirected graph has n nodes and m edges. Print the number of connected components. Input format: First line: n and m. Next m lines: u v. Output format: Print the component count. Constraints: 1 <= n <= 3654; 0 <= m <= 7308; 1 <= u,v <= n.

Example 1:

Input: 2045 2539 456 803 1022 1359 1111 1903 167 426 194 989 730 1515 108 902 630 1664 140 517 981 1001 969 1201 236 843 1089 1274 1322 1642 1203 1575 172 808 952 1541 1133 1746 579 1065 775 1447 62 1215 1342 1898 964 1666 1053 1131 544 1435 405 1307 867 1877 184 1269 1297 1544 858 1817 152 417 26 222 201 1851 706 945 966 1735 1092 1167 431 692 806 1799 1038 1824 375 1727 1040 1725 313 1496 561 788 72 1035 427 1374 709 1476 460 1385 111 1899 698 1306 935 965 326 755 1413 1558 102 755 1331 1361 664 940 1605 1888 221 648 489 1050 1115 1324 154 1149 1791 1923 621 1740 348 1192 585 1015 175 567 608 1481 148 1699 495 1200 266 1514 385 1496 938 963 496 722 1187 1674 1335 1354 787 1513 31 1678 169 972 398 1495 304 1479 639 841 297 972 189 1140 796 1686 969 1446 990 1800 303 485 451 630 887 1229 160 583 …
Output: 206

Example 2:

Input: 2731 5919 297 1659 1897 2174 2109 2714 529 2611 1129 2106 449 1245 1802 2429 1148 2084 1 982 1053 1682 668 1805 1056 1270 699 1121 1578 2724 1836 2242 1842 2299 494 1413 580 2491 849 1804 218 489 1026 1556 331 1185 616 886 698 2551 1232 1934 38 1930 800 1956 984 2723 1192 1925 87 1665 717 1359 829 1306 1049 1108 1669 2366 33 2575 524 1337 109 1311 66 304 977 1837 6 1464 1557 1581 154 2546 2312 2445 293 1779 1251 2288 1507 1731 1410 2137 373 2318 233 1879 934 2290 696 1875 1277 2478 1396 2482 163 1856 1840 2040 623 2723 312 1388 203 958 1010 1386 1508 2615 1608 2138 634 2603 1721 2126 244 2425 427 1710 77 1267 384 518 1656 1757 516 2234 1619 2150 1012 2263 1424 1457 155 786 193 657 1405 1779 1593 2051 431 754 395 869 484 1754 628 1196 1794 2647 989 1040 1477 1796 1608 2379 322 585 2048 2137…
Output: 43

Example 3:

Input: 2234 952 650 1691 130 545 198 1225 829 2165 228 1766 489 1675 592 1770 1052 1230 1304 1798 1419 1472 1607 1748 1352 1819 1772 2000 1211 1749 1872 2136 1458 2119 1584 1722 525 1123 137 1318 415 1736 446 1631 872 1894 52 1329 459 637 791 1006 125 1803 632 837 981 2206 77 1690 1699 1737 81 2035 395 2018 556 2100 1643 2033 257 818 1860 2119 331 876 2023 2046 119 1605 1898 2103 243 1779 1221 1320 942 1619 165 1594 389 936 239 392 389 1619 670 1468 313 723 1287 1935 976 1806 1412 1577 1127 1238 1689 1921 1256 1269 668 806 19 1871 44 970 1679 1762 666 1976 478 2210 1657 2129 146 1538 1276 1556 574 2140 1219 1687 922 1062 915 1878 305 612 1604 1715 796 1540 100 181 1661 2151 930 2089 551 1455 843 1639 1359 2226 755 1260 625 1297 800 1813 211 1332 612 1668 196 1850 319 1971 436 712 1433 1517 1332 1…
Output: 1283

Constraints:

1 <= n <= 3654; 0 <= m <= 7308; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
The Separate Camps of Horselord Plains - MEDIUM Coding Problem | CodeTikki