CT37629

The Separate Camps of Echo Dunes

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the singing sands of Echo Dunes, Seth the valuer keeps careful count of the canals. Catalog the new acquisitions, every figure matters. 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 <= 3037; 0 <= m <= 6074; 1 <= u,v <= n.

Example 1:

Input: 285 3899 182 222 54 218 10 29 11 251 14 55 81 98 38 131 225 244 27 45 160 188 151 213 112 145 119 125 98 197 131 259 124 219 78 240 8 247 2 190 99 243 78 131 159 176 81 180 132 226 27 33 127 266 30 47 17 235 91 245 73 182 89 251 47 144 210 281 183 278 2 125 89 163 198 268 70 277 52 267 35 181 40 64 77 167 4 283 15 46 31 193 98 100 148 161 31 180 43 54 152 153 51 236 77 272 29 151 127 162 186 197 40 242 144 244 2 103 24 205 5 74 242 244 264 273 106 115 53 78 20 157 30 203 29 242 54 89 51 260 52 184 228 270 239 281 167 253 80 208 32 252 83 251 9 60 36 229 36 39 34 220 84 168 17 219 71 96 96 267 117 166 49 228 152 170 141 187 77 151 55 104 202 285 34 179 93 134 248 259 109 273 123 187 26 29 115 262 6 256 64 67 205 241 50 77 71 163 169 185 1 4 15 175 246 277 163 183 31 132 173 202 27 142 63 68…
Output: 1

Example 2:

Input: 1875 1636 692 1287 975 1109 411 1426 468 1163 1232 1744 954 1273 445 983 510 753 895 1149 76 135 847 960 111 766 931 1066 491 1759 198 467 802 1142 984 1027 158 704 929 1163 428 469 26 582 289 718 483 784 105 375 140 1871 840 1511 1086 1572 1471 1632 1568 1758 68 655 288 1735 901 1153 435 705 1482 1660 296 1815 1283 1676 252 333 1450 1555 570 881 676 1419 1373 1752 679 1158 473 655 477 595 765 1404 869 1734 1229 1714 1541 1812 1003 1256 634 1528 1396 1817 508 1013 161 1650 167 1272 213 798 439 880 95 1185 222 1214 1013 1272 1510 1526 928 1537 1550 1676 339 1732 278 1131 198 568 1017 1825 622 1327 946 1272 1031 1266 667 1603 414 581 34 1758 1269 1742 910 1861 135 1201 226 1666 321 1105 436 1386 48 1382 403 1028 1086 1715 378 1509 697 1389 246 425 269 617 553 971 525 1666 274 316 1613 1763 1…
Output: 402

Example 3:

Input: 2836 2609 777 1578 1051 2039 1897 2749 1935 2218 1436 2063 472 2263 141 427 948 1144 229 795 1227 1306 581 2818 883 1483 257 1890 1877 2013 1839 2658 151 453 667 2276 1535 2199 1314 2034 57 781 1766 2622 1350 1873 1279 1885 235 1653 1076 1341 753 948 292 2135 607 1349 251 2776 954 1116 1527 2162 35 1877 2244 2698 754 793 428 1377 1083 2690 1165 2161 1777 1913 1386 1693 284 1098 1381 2333 213 1251 644 1085 612 1583 576 1537 550 1058 921 1109 24 465 476 1874 1368 1432 1865 2621 869 2320 983 1870 1262 2000 430 1924 34 2828 533 2344 284 290 1247 1936 754 1048 373 1797 335 2554 651 1386 207 1060 737 1641 796 1323 1060 2052 1103 1969 337 2196 2515 2574 435 1621 579 1811 1786 2029 2046 2707 231 587 1070 2680 1821 2094 594 2308 358 771 341 871 1113 1987 1371 1758 15 1549 1488 2506 1042 2269 1818 2…
Output: 564

Constraints:

1 <= n <= 3037; 0 <= m <= 6074; 1 <= u,v <= n.

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