CT49811

The Separate Camps at Gearford

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the clockwork quarter of Gearford as Tanner unrolls the day's manifest of canals. The tally will decide the next shipment. 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 <= 1326; 0 <= m <= 2652; 1 <= u,v <= n.

Example 1:

Input: 447 2350 119 159 265 361 71 246 150 439 112 113 290 370 39 254 171 424 33 163 308 395 7 288 27 251 76 280 103 266 240 372 274 345 260 374 316 439 18 155 124 148 89 295 80 223 59 263 180 441 97 339 410 430 257 299 20 333 64 317 277 287 97 196 17 313 175 258 293 417 30 183 249 409 299 405 108 184 116 348 288 367 174 295 76 140 319 438 201 236 4 259 14 155 39 143 134 143 83 397 40 235 246 379 127 300 134 242 361 386 12 88 258 362 268 282 64 256 53 177 92 396 2 294 21 98 134 345 348 406 8 443 2 145 10 275 74 289 116 443 22 143 82 141 132 316 281 324 163 211 215 312 168 447 73 286 432 443 257 354 73 182 129 343 52 252 138 231 139 339 111 319 246 447 94 213 13 66 285 311 404 428 246 442 105 422 206 421 205 327 38 286 284 443 128 349 134 332 39 288 69 116 271 422 114 357 10 406 191 274 326 354 30…
Output: 1

Example 2:

Input: 939 2138 881 929 10 191 724 791 109 176 263 719 331 774 512 754 112 469 322 380 725 861 163 217 82 631 540 720 12 430 665 807 10 792 346 381 86 475 269 713 204 465 404 808 211 898 197 659 516 563 146 611 68 525 595 768 150 368 336 666 283 551 586 733 336 695 341 449 556 565 487 755 96 626 219 686 104 294 276 547 385 910 479 524 73 104 224 439 494 499 261 591 146 699 339 658 348 809 178 400 191 537 389 540 60 720 600 888 165 332 122 434 80 526 160 717 495 782 220 536 717 821 195 778 744 774 834 844 27 560 722 742 733 752 550 879 220 665 309 312 298 447 774 937 119 184 78 931 219 500 56 597 180 471 208 596 470 494 32 833 30 613 419 820 239 650 139 625 170 841 658 760 567 726 157 607 478 560 20 471 122 716 470 683 538 794 2 688 8 853 51 66 703 712 829 875 412 899 476 803 597 741 617 870 93 71…
Output: 10

Example 3:

Input: 1140 1571 42 145 572 668 219 799 176 510 415 826 503 977 279 717 333 1056 267 502 361 467 1031 1053 178 660 232 357 681 1092 227 722 47 603 158 446 146 1057 361 1048 650 766 667 972 66 544 734 865 60 190 171 188 603 1115 6 30 522 910 306 314 102 795 516 704 373 381 82 804 600 1137 246 283 1103 1123 292 751 366 601 699 725 742 813 1035 1112 313 676 603 689 82 1017 794 1101 267 742 127 352 913 988 328 1075 172 717 394 791 710 941 310 1073 256 648 520 1084 377 403 350 1048 81 200 192 1024 121 876 519 592 243 816 581 1004 730 887 92 555 225 381 835 868 415 795 531 619 317 449 257 486 550 1063 2 560 573 793 187 775 648 963 472 524 465 1126 179 308 483 632 533 744 99 1098 979 1003 794 940 623 1010 249 1059 417 825 280 954 413 873 592 1062 453 779 68 227 491 778 419 713 150 1121 223 852 531 717 1…
Output: 88

Constraints:

1 <= n <= 1326; 0 <= m <= 2652; 1 <= u,v <= n.

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