CT33311

The Sable Separate Camps

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Petra found an old ledger of canals in the dairy attic at the floating docks of Skyharbor. The margin notes pose a precise question. 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 <= 1477; 0 <= m <= 2954; 1 <= u,v <= n.

Example 1:

Input: 1382 508 469 571 52 346 203 1055 93 687 69 1152 985 1146 324 541 743 1146 759 864 690 1074 276 735 462 826 313 520 51 1100 1058 1281 459 1266 438 1139 53 907 633 782 539 1091 477 754 43 297 392 486 46 704 660 727 731 1282 732 1044 422 1225 310 1153 972 1251 919 941 1187 1247 715 1279 881 1243 86 500 93 523 1273 1374 1282 1328 145 923 874 906 47 101 382 1316 503 573 168 788 337 1227 1048 1168 279 1170 589 816 414 691 450 1373 74 978 303 485 305 841 331 694 16 561 205 277 179 763 534 912 263 540 175 196 1062 1207 90 822 3 226 271 573 399 589 774 1016 543 1150 563 1376 220 728 583 1144 752 935 765 796 36 290 140 706 1134 1225 18 1196 13 770 115 582 334 814 58 1345 557 652 247 1004 270 1259 830 1321 706 1275 1163 1209 668 1034 234 1015 165 419 59 787 903 1088 1026 1108 1049 1071 498 588 1273 1…
Output: 874

Example 2:

Input: 1328 671 386 1179 440 1073 262 489 347 899 1126 1267 366 1286 199 737 103 653 323 768 12 314 646 647 362 780 921 1312 513 672 510 766 856 1227 46 1206 1116 1301 1042 1268 547 723 56 963 251 501 161 795 436 1240 945 1151 651 690 1001 1069 880 986 333 396 79 1000 103 855 382 1274 245 1287 161 300 513 1086 396 459 201 754 802 1122 166 683 12 1058 546 1257 12 1048 433 1305 948 956 30 1154 550 568 388 668 825 1144 703 875 154 1085 39 114 720 1076 71 792 103 697 146 385 759 984 112 342 168 1194 678 863 565 749 526 863 34 411 654 842 600 909 79 86 937 1118 726 753 291 1096 292 1100 400 908 739 834 815 847 609 1097 697 1067 855 992 1227 1252 623 1266 927 1138 65 1210 630 996 280 1085 155 920 70 103 16 708 20 823 307 1249 464 560 177 246 207 1223 83 194 890 1230 512 1126 406 839 83 1017 1119 1325 1…
Output: 659

Example 3:

Input: 956 172 360 833 62 531 298 502 294 700 62 565 599 743 144 844 594 839 101 303 611 842 217 885 552 920 135 703 567 695 157 594 313 494 291 375 137 930 304 616 659 691 347 773 301 534 170 593 3 502 243 324 632 924 388 561 384 754 688 778 852 871 351 782 705 810 532 838 204 686 204 747 423 811 144 888 54 681 906 921 27 667 901 944 95 197 348 739 224 361 344 754 583 833 143 746 67 430 538 688 112 774 265 398 628 810 340 614 548 613 498 833 23 879 240 470 514 899 786 831 257 684 731 951 164 362 397 886 119 735 330 733 606 909 351 850 550 636 377 675 517 799 254 448 283 422 72 675 446 779 82 424 479 838 815 935 91 651 341 906 251 274 101 892 297 590 333 560 192 399 531 914 301 613 295 362 378 849 164 715 466 543 484 781 430 446 509 768 198 537 477 789 171 721 127 525 99 131 352 452 749 868 115 1…
Output: 784

Constraints:

1 <= n <= 1477; 0 <= m <= 2954; 1 <= u,v <= n.

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