CT31702

Rekha's Separate Camps Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the wheat plains of Amberfield, Rekha studies rows of roads entries. One clean number will settle the guild's oldest argument. 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 <= 1113; 0 <= m <= 2226; 1 <= u,v <= n.

Example 1:

Input: 940 738 51 806 467 805 504 597 437 737 779 786 326 657 274 540 153 279 202 727 4 725 111 216 549 747 174 918 627 881 549 668 306 572 138 140 416 512 63 673 322 746 599 747 189 316 605 901 41 840 230 385 24 676 36 793 121 519 60 61 284 608 261 413 582 771 407 839 273 303 25 862 121 274 80 932 335 509 92 628 345 792 19 766 185 711 573 827 249 769 150 170 32 442 154 828 488 912 570 878 62 425 635 652 637 933 89 258 388 654 701 719 525 633 249 711 26 258 368 766 559 923 326 914 789 814 509 853 207 802 317 796 908 912 133 612 338 527 592 694 170 308 241 861 473 585 80 687 873 925 478 558 350 689 59 883 52 91 534 829 675 821 132 855 175 670 474 709 10 328 47 923 397 523 53 226 297 672 254 758 245 717 117 283 803 855 161 833 227 809 695 907 530 807 158 346 76 367 319 363 434 511 46 174 396 495 56…
Output: 244

Example 2:

Input: 625 706 247 456 311 392 275 530 48 540 347 475 393 586 461 599 170 172 380 508 356 448 143 568 335 474 140 436 417 440 544 552 109 199 204 404 57 605 311 413 77 622 26 97 68 269 26 253 2 552 212 610 297 303 93 493 505 598 492 582 45 187 112 614 229 600 62 454 191 228 47 61 97 176 169 278 41 227 468 541 356 571 238 555 149 373 176 527 44 128 189 458 219 427 375 554 230 297 171 509 233 332 157 465 166 364 454 482 171 384 162 380 119 251 289 343 70 365 372 599 1 155 155 292 170 477 138 577 419 441 67 623 11 186 78 113 154 219 230 267 300 375 174 459 9 52 169 247 525 596 290 347 124 512 329 384 53 327 115 248 236 612 480 623 543 589 66 177 63 162 484 605 70 250 534 545 454 601 238 411 61 326 73 394 63 302 12 55 81 135 199 591 283 581 188 583 122 325 10 189 276 332 189 506 286 555 249 276 564 5…
Output: 81

Example 3:

Input: 899 700 492 643 638 679 87 271 788 825 736 808 11 91 103 409 117 747 619 776 17 620 48 724 793 794 355 528 173 779 129 815 2 400 267 897 240 499 3 54 7 555 267 557 39 788 713 785 96 726 175 575 442 707 245 487 34 644 126 173 520 612 307 697 294 633 221 361 1 366 609 752 583 892 272 802 588 679 269 607 512 786 211 668 357 608 398 435 192 383 454 697 580 854 223 249 326 777 85 673 387 418 565 851 731 883 231 527 326 671 358 877 253 390 370 682 528 620 398 446 81 533 511 692 260 479 269 588 168 592 87 500 396 575 248 442 523 695 648 781 449 719 283 311 643 798 26 49 581 763 398 585 56 728 526 683 421 443 109 845 67 112 14 446 439 654 205 562 280 772 629 688 625 640 143 531 411 438 146 683 27 661 345 599 543 885 228 708 14 586 751 877 358 465 23 393 154 613 658 792 173 850 218 723 78 676 82 65…
Output: 256

Constraints:

1 <= n <= 1113; 0 <= m <= 2226; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
Rekha's Separate Camps Ledger - MEDIUM Coding Problem | CodeTikki