CT45325

The Separate Camps at Bluehollow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the indigo vats of Bluehollow with crates of roads, and Elio the log keeper must account for every last one. 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 <= 1034; 0 <= m <= 2068; 1 <= u,v <= n.

Example 1:

Input: 999 881 534 607 112 855 163 320 911 922 117 701 114 652 18 797 186 191 98 973 81 240 14 312 694 743 130 423 522 536 530 792 98 996 478 891 214 452 446 522 346 970 117 630 210 471 182 298 50 819 239 996 681 912 383 702 156 638 213 655 522 530 359 752 131 968 80 704 331 881 598 861 169 987 538 923 70 170 73 539 715 800 221 782 234 454 725 815 776 852 792 867 34 515 267 643 375 865 549 682 472 738 708 829 277 794 263 520 343 454 346 708 136 243 299 929 257 468 481 726 303 541 200 728 310 321 357 967 124 404 39 863 84 678 296 310 604 877 325 375 188 441 515 759 593 615 601 624 230 587 108 820 155 569 436 466 140 635 748 769 594 808 202 770 83 242 79 648 81 574 65 95 20 62 327 553 958 979 112 728 333 708 123 177 571 591 326 761 440 819 388 985 419 563 211 455 594 983 233 661 487 773 129 940 175…
Output: 220

Example 2:

Input: 438 122 134 353 6 436 276 346 34 340 268 290 153 392 85 108 58 232 123 217 223 246 6 78 214 330 186 320 231 423 196 341 63 166 40 320 306 417 79 189 155 214 400 434 58 389 165 424 249 366 87 159 107 230 102 150 73 265 309 408 308 371 180 423 215 273 32 390 77 221 202 291 242 373 25 65 16 238 172 278 322 395 194 311 22 222 108 435 105 216 115 420 111 129 64 350 63 211 194 200 83 343 319 401 138 193 291 386 18 303 97 234 272 419 262 384 61 267 283 348 379 405 26 277 105 360 27 139 77 267 190 319 149 420 10 77 268 300 150 355 127 308 200 300 120 344 267 321 117 136 43 309 147 415 126 260 200 334 63 130 142 281 34 159 314 405 71 328 199 421 27 172 361 365 201 421 142 294 170 274 191 420 124 414 101 384 146 366 106 378 229 437 8 379 139 340 48 154 289 321 71 153 141 322 76 300 160 401 216 303 2…
Output: 316

Example 3:

Input: 691 1735 419 576 213 415 162 296 554 680 267 360 134 545 116 219 38 487 300 593 54 238 460 630 399 586 279 343 175 454 448 520 247 485 209 469 522 650 247 404 203 478 84 404 326 664 199 525 458 678 354 526 190 567 145 297 183 294 549 564 64 375 124 484 200 542 65 572 348 474 149 470 296 376 430 431 74 375 396 429 315 661 437 541 286 445 306 377 145 680 14 671 198 466 458 672 131 596 89 95 445 600 192 316 182 412 211 632 104 609 430 570 350 507 29 91 238 391 253 419 39 148 546 628 565 578 56 374 61 432 460 664 341 446 71 638 216 429 148 626 9 374 278 468 561 576 5 532 68 453 208 657 128 401 37 337 475 500 286 480 1 360 575 683 440 592 254 426 17 111 291 689 326 656 40 290 8 237 230 527 453 519 136 358 33 125 470 604 203 433 332 629 168 223 96 617 335 531 270 691 397 462 230 472 570 670 116 …
Output: 7

Constraints:

1 <= n <= 1034; 0 <= m <= 2068; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
The Separate Camps at Bluehollow - MEDIUM Coding Problem | CodeTikki