CT38579

The Separate Camps Beneath Galeholm

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the zephyr cliffs of Galeholm with crates of bridges, and Kate the surveyor 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 <= 2083; 0 <= m <= 4166; 1 <= u,v <= n.

Example 1:

Input: 1302 2800 569 598 908 1073 403 1117 37 1185 24 873 1044 1174 112 637 476 873 588 1204 354 1027 902 1235 627 701 65 604 398 804 503 815 1058 1201 52 420 750 1300 723 739 474 843 10 61 887 1241 995 1008 460 794 525 879 67 497 1051 1083 157 1083 302 948 6 209 74 706 429 1197 707 898 754 1089 77 1221 785 905 848 950 63 156 435 564 496 1143 111 118 186 425 839 937 327 770 341 806 715 1098 767 1122 304 820 304 777 986 1057 182 812 147 826 218 311 115 574 61 1042 106 457 867 1095 28 1030 82 508 38 1132 810 992 205 401 506 660 1 113 44 260 449 1269 330 1171 68 1160 284 441 399 503 714 826 124 682 755 1130 309 848 64 121 103 825 984 1125 172 602 452 848 1 483 396 1273 430 1112 163 748 158 615 506 1264 156 421 379 999 71 413 99 500 405 725 454 716 488 1232 988 1282 331 848 335 543 477 856 164 825 48…
Output: 17

Example 2:

Input: 720 952 433 636 322 448 52 150 578 683 8 108 556 619 38 249 118 715 224 627 245 492 303 520 346 428 27 449 475 522 181 648 25 508 697 715 268 506 244 289 198 615 436 685 598 687 131 403 377 451 236 315 311 482 312 390 486 572 94 215 517 577 673 680 13 142 148 580 125 186 305 518 196 370 612 712 76 510 100 634 236 259 204 492 49 252 342 638 15 401 205 446 232 345 546 712 67 674 425 627 171 431 123 171 464 547 58 191 35 291 83 720 363 376 257 712 436 481 202 557 33 105 76 105 34 685 290 624 441 611 9 338 45 406 294 447 173 300 331 378 271 290 651 667 343 684 54 635 246 569 318 714 472 567 287 458 43 701 152 353 494 543 131 347 123 265 350 630 282 298 516 577 134 139 287 321 124 574 358 680 304 316 643 649 31 80 238 244 213 260 120 211 295 400 21 506 6 323 49 471 111 132 708 709 145 649 566 7…
Output: 54

Example 3:

Input: 527 596 315 417 132 356 103 278 161 383 145 210 73 236 272 417 109 289 43 419 6 372 288 500 18 423 307 469 250 290 180 428 241 466 168 389 79 260 19 408 84 283 122 135 295 410 150 191 178 350 147 463 75 325 51 111 68 447 169 262 64 172 52 452 86 361 289 500 52 227 320 456 157 252 391 460 59 372 72 496 30 388 46 497 163 517 118 204 86 234 154 471 249 276 99 153 293 504 95 154 423 449 220 478 210 308 53 490 77 335 77 409 79 307 52 188 100 114 95 123 52 106 243 495 7 75 123 338 2 414 195 334 154 472 159 455 148 378 333 455 34 381 163 516 21 228 38 165 18 460 358 461 23 118 134 192 334 438 91 197 21 291 200 514 183 376 74 518 245 497 267 403 92 510 58 257 114 387 102 168 424 506 233 259 175 207 96 308 278 338 55 490 51 431 180 409 277 394 157 209 80 513 95 127 510 523 12 69 153 213 45 346 243 …
Output: 63

Constraints:

1 <= n <= 2083; 0 <= m <= 4166; 1 <= u,v <= n.

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