CT34310

Jace and the Faded corridors

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the cedar groves of Balmcrest pays by the answer, and Jace intends to earn it. First: the full register of corridors. 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 <= 1375; 0 <= m <= 2750; 1 <= u,v <= n.

Example 1:

Input: 992 234 320 880 72 458 532 925 437 469 105 400 579 644 463 966 489 697 141 659 625 877 322 765 742 809 738 854 373 855 126 176 112 689 395 751 450 728 226 250 534 696 45 668 278 472 768 772 125 955 497 868 37 85 595 788 173 818 10 557 401 583 173 830 69 819 509 628 778 984 311 906 350 814 152 311 54 145 130 583 330 682 527 607 221 619 358 766 243 972 372 795 38 125 477 628 89 827 267 682 172 861 25 91 426 589 509 735 102 460 242 788 137 501 93 961 807 841 75 202 283 835 235 440 51 718 171 470 98 544 193 853 152 494 133 589 291 630 835 961 659 711 771 970 696 865 11 673 559 816 214 621 181 544 835 979 728 915 51 964 473 766 874 952 184 625 389 738 632 893 524 646 660 856 213 460 619 658 675 711 241 723 498 628 116 690 210 337 284 288 72 828 447 654 107 423 54 75 813 871 464 469 558 780 374 …
Output: 758

Example 2:

Input: 425 1535 226 241 43 358 141 161 303 325 57 230 17 99 146 350 19 102 54 124 101 379 82 403 112 370 96 339 87 312 159 353 283 392 15 304 171 393 95 349 41 126 187 394 241 307 3 267 120 294 81 187 190 317 69 100 282 421 140 307 48 192 75 212 121 373 195 366 273 283 225 356 28 88 260 381 269 310 127 231 133 340 159 317 215 373 46 272 248 406 201 256 335 348 126 207 84 269 62 82 103 326 214 230 273 395 180 359 149 340 158 423 143 274 216 302 119 167 142 174 115 329 54 91 73 336 64 100 117 406 388 412 140 406 3 208 93 173 234 361 328 375 383 393 131 222 85 295 132 166 41 144 218 287 228 235 172 205 21 334 67 301 354 362 67 381 27 286 96 151 94 362 187 328 316 346 49 378 43 187 157 244 296 389 94 316 74 373 177 346 222 278 112 267 141 146 21 173 169 218 272 318 46 75 151 308 33 306 86 365 80 352 …
Output: 1

Example 3:

Input: 1043 1475 896 1012 202 936 244 807 477 791 380 646 111 1020 30 592 218 919 668 991 37 524 596 745 716 993 269 414 235 547 254 283 49 358 114 608 747 785 681 738 393 997 119 867 637 861 276 391 100 700 513 1012 70 431 510 955 219 555 58 869 235 1034 678 752 223 692 393 670 7 752 740 994 337 387 157 449 1 122 408 460 374 964 210 412 90 972 63 274 77 120 184 679 16 638 151 352 1 536 146 157 654 866 112 254 102 1017 312 925 455 606 384 406 195 1038 487 807 271 809 165 185 29 865 722 742 44 843 302 466 193 360 923 968 571 699 280 480 224 698 855 906 70 521 590 740 733 1007 131 477 73 852 144 293 656 827 274 952 13 626 347 916 425 542 707 951 224 470 608 779 72 408 661 1010 855 1019 266 519 101 496 22 571 226 880 436 831 836 839 410 466 701 992 184 855 319 658 675 887 209 414 712 862 399 402 5 7…
Output: 61

Constraints:

1 <= n <= 1375; 0 <= m <= 2750; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
Jace and the Faded corridors - MEDIUM Coding Problem | CodeTikki