CT45818

The Umber Separate Camps

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the opal reefs of Shimmerdeep pays by the answer, and Faye 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 <= 2551; 0 <= m <= 5102; 1 <= u,v <= n.

Example 1:

Input: 1754 1573 185 752 494 1492 1438 1715 887 1317 81 573 1088 1430 160 662 729 1339 1047 1068 6 134 40 89 71 360 22 152 338 1363 398 1052 330 1130 676 1628 1097 1307 398 1011 618 1256 900 1590 982 1106 608 1342 1028 1272 133 722 1365 1659 761 1182 107 1556 805 909 636 781 1469 1643 964 1146 258 1321 387 768 311 1189 26 323 288 1408 1265 1645 613 755 680 1378 59 1648 1542 1586 139 609 351 633 442 1138 515 1244 362 1448 333 1668 812 1713 635 1718 453 870 371 905 1102 1282 1182 1268 275 753 98 1092 884 1654 764 816 1026 1719 566 1553 159 629 180 1024 479 1625 59 905 7 888 393 1402 38 446 895 1243 405 423 57 753 144 1377 1092 1743 372 718 704 1736 317 392 348 676 545 947 173 648 1569 1725 401 839 611 1318 1145 1624 57 338 551 1229 499 954 482 1311 1359 1520 84 302 53 1418 343 1611 174 1628 191 597…
Output: 355

Example 2:

Input: 548 4956 303 433 303 393 11 138 142 149 172 303 150 266 23 292 41 522 272 297 16 510 493 521 315 473 96 212 136 192 49 355 211 541 76 314 209 236 113 236 11 50 383 491 102 385 422 464 29 211 137 354 177 277 156 266 8 478 209 272 308 342 257 497 99 158 402 457 57 195 147 308 271 407 408 517 92 231 104 198 7 423 427 521 5 260 146 376 168 547 45 263 375 486 16 308 10 422 301 420 345 490 511 530 46 497 199 229 87 464 334 433 276 417 204 497 54 180 164 548 167 182 128 396 256 353 226 265 348 375 152 307 111 363 500 517 103 139 129 279 394 411 234 402 71 120 448 467 144 450 123 300 12 349 406 514 107 212 291 482 200 438 119 153 395 506 27 136 3 454 362 434 338 394 135 150 105 516 121 137 240 340 137 394 143 258 388 447 45 287 114 541 142 449 16 94 2 288 466 485 119 286 257 517 168 191 219 536 33…
Output: 1

Example 3:

Input: 2519 4687 61 1379 763 2482 232 1245 340 1794 164 299 126 165 407 1103 200 1990 2331 2424 1092 1861 659 1968 703 1580 525 1196 38 2202 72 2365 356 1109 516 549 297 863 23 1476 42 137 336 892 715 1318 128 1229 200 344 259 936 360 2154 1165 2467 1866 2290 446 1576 936 1735 680 932 1078 2299 117 267 2054 2370 416 1602 711 1357 72 2324 1016 1569 296 1179 2144 2436 1001 2091 741 2350 1209 2024 2430 2476 1220 1415 547 1869 1070 1186 351 1140 198 920 39 2009 457 1126 2260 2426 2021 2174 571 947 1186 1481 456 1730 210 394 945 1894 1687 1898 1693 1806 1250 2089 2222 2519 506 2206 102 353 1494 2430 1370 2395 420 1270 610 1106 99 2516 1642 1687 958 2402 513 1549 1264 2484 545 1457 133 1452 52 2093 2022 2026 829 1254 739 1572 1283 2278 534 2500 1174 2074 121 1693 258 1219 575 2477 193 725 573 2409 103 …
Output: 64

Constraints:

1 <= n <= 2551; 0 <= m <= 5102; 1 <= u,v <= n.

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