CT38767

The tunnels Separate Camps Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Manav the scribe watches over the port of Emberfall's stores of tunnels. A careful computation stands between order and chaos. 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 <= 1061; 0 <= m <= 2122; 1 <= u,v <= n.

Example 1:

Input: 758 173 70 696 5 256 539 573 308 371 109 607 57 467 527 686 337 670 161 428 664 736 549 686 30 587 136 680 572 702 97 181 262 432 266 378 157 187 296 527 504 542 17 105 41 160 105 148 353 629 178 692 3 584 311 607 499 757 144 577 304 342 214 401 431 514 57 550 373 377 69 594 592 618 259 508 296 362 38 235 258 565 427 743 122 576 315 750 475 483 437 536 496 561 240 742 197 258 18 512 322 716 1 434 351 424 506 690 91 134 202 539 71 713 54 689 133 614 56 379 17 494 33 375 276 353 349 458 325 591 155 417 168 571 316 616 137 463 295 549 298 432 350 593 406 449 257 440 183 254 305 694 173 547 105 376 303 618 396 698 237 415 265 626 292 355 189 742 4 464 28 268 361 673 153 288 224 244 104 217 395 562 392 694 59 377 79 556 216 720 363 535 562 573 360 509 319 369 157 208 507 514 314 442 107 336 167…
Output: 585

Example 2:

Input: 703 411 329 631 381 421 75 417 10 251 173 577 381 515 402 696 364 421 21 184 92 433 404 495 97 477 222 235 385 582 319 424 199 569 566 615 569 628 81 419 305 310 77 351 119 560 575 659 212 443 485 632 22 240 93 305 60 331 205 235 265 375 380 488 467 472 473 477 450 620 212 660 106 197 506 608 322 675 186 315 209 682 119 254 168 546 164 287 2 344 307 488 6 509 54 442 184 209 3 247 266 608 323 581 320 486 298 492 288 411 407 475 243 578 275 625 21 64 91 430 208 222 391 701 360 427 12 252 318 465 127 657 112 418 348 602 165 173 109 303 374 562 144 381 560 633 137 499 51 647 554 646 163 661 357 462 495 683 279 391 317 624 67 279 96 147 339 576 80 376 143 303 38 65 293 350 269 581 399 665 68 176 32 415 673 694 122 531 284 667 95 306 418 628 342 426 80 489 510 590 354 488 100 302 428 690 173 549…
Output: 295

Example 3:

Input: 20 18 3 17 3 18 4 5 12 17 13 15 9 15 2 18 19 20 7 17 1 14 2 11 3 10 5 20 12 15 10 20 6 11 1 4 15 17
Output: 3

Constraints:

1 <= n <= 1061; 0 <= m <= 2122; 1 <= u,v <= n.

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