CT43536

The Sterling corridors of Qadir

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the bamboo terraces of Verdantstep; Qadir weighs the day's corridors manifests and starts the calculations. 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 <= 2809; 0 <= m <= 5618; 1 <= u,v <= n.

Example 1:

Input: 803 1881 536 574 279 540 399 736 526 549 110 328 227 320 674 767 339 505 26 95 249 260 493 788 669 713 697 743 466 745 296 510 338 597 37 703 476 744 98 663 132 420 86 128 42 562 606 638 304 634 146 251 308 547 478 622 488 559 281 733 162 720 361 746 4 147 16 598 159 430 435 501 329 777 462 568 540 703 64 490 11 688 205 482 55 184 492 795 582 771 100 508 595 635 184 209 400 607 481 541 115 585 349 429 526 680 19 532 641 680 404 571 37 613 382 461 250 281 477 532 408 620 99 161 73 346 147 626 206 468 150 420 87 417 283 461 14 659 214 520 114 592 250 372 61 244 86 514 263 278 125 757 513 762 213 539 75 113 23 565 506 629 186 620 56 449 164 187 116 215 398 707 42 422 134 501 135 307 223 545 47 601 103 168 358 654 342 798 53 431 296 540 325 782 575 712 36 191 463 707 211 603 71 153 454 803 128…
Output: 4

Example 2:

Input: 2650 3986 1658 2449 852 1715 1104 1847 555 2014 504 601 382 552 841 2396 1845 2457 663 1806 952 1053 114 2039 1090 1358 249 430 106 945 479 961 1112 2005 1475 2238 1249 2306 2150 2321 1294 1923 1451 1845 15 1656 323 743 1341 2600 1316 1523 1051 1528 1331 1475 1976 1992 164 1310 96 1109 617 2364 176 409 350 1458 728 1002 1143 2064 544 796 161 1241 455 1777 284 770 558 1112 300 1944 362 1207 791 1881 868 1244 1019 1617 413 2312 98 343 1035 1555 1806 2491 631 2522 918 1119 1626 2502 257 2603 552 1221 1521 2225 395 2165 418 887 138 884 356 1361 725 2090 868 1555 267 2088 1280 2047 244 349 931 1375 1516 2152 1140 2297 201 1311 146 196 400 777 965 1384 309 2369 1717 2470 245 747 450 1365 2184 2625 18 2577 1923 2069 787 1004 933 2007 620 1058 738 761 1727 2151 631 1770 1352 1927 1737 2517 20 2215…
Output: 140

Example 3:

Input: 1615 1787 39 1162 211 387 164 1115 749 1175 1281 1355 686 951 442 482 217 872 1220 1385 108 391 808 961 208 265 451 758 936 1262 1028 1333 181 1554 209 948 135 628 1001 1078 77 177 780 1311 722 1213 545 832 1224 1334 513 1043 669 1484 1115 1458 455 848 705 707 142 1344 298 1506 116 1594 95 416 416 1143 684 1407 608 710 910 1457 351 605 417 547 215 1226 306 351 599 1372 1026 1561 317 1114 1466 1518 266 993 1239 1249 11 1155 1134 1263 1178 1233 1042 1472 1387 1403 287 994 328 1495 457 869 246 1514 710 865 137 344 13 98 304 473 1187 1438 1552 1577 626 1003 1041 1150 61 1474 750 1331 292 725 49 146 615 976 653 1304 619 1015 659 1122 802 1325 975 1217 381 1198 678 1484 3 1045 297 443 175 1537 341 1070 174 1068 996 1581 185 501 436 567 537 660 960 1321 854 1391 601 698 311 658 140 844 102 936 48…
Output: 237

Constraints:

1 <= n <= 2809; 0 <= m <= 5618; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
The Sterling corridors of Qadir - MEDIUM Coding Problem | CodeTikki