CT34199

Last tunnels of Curator

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the ribbon falls of Cascade Vale pays by the answer, and Curator intends to earn it. First: the full register of tunnels. 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 <= 799; 0 <= m <= 1598; 1 <= u,v <= n.

Example 1:

Input: 702 1054 27 38 132 559 106 549 308 324 161 187 453 480 5 292 278 313 212 490 92 603 96 337 90 179 149 585 233 453 537 618 346 641 443 694 166 241 232 454 201 432 456 500 353 505 589 632 280 695 476 575 377 474 528 702 453 498 189 452 120 457 132 428 295 505 121 554 350 605 404 676 249 649 315 622 272 369 399 402 455 690 66 282 596 700 446 486 207 376 363 409 473 529 79 656 133 630 219 253 118 263 17 147 197 584 576 675 29 82 106 200 54 538 349 361 211 622 155 468 136 160 24 664 137 471 125 496 93 158 17 380 17 155 377 572 58 293 429 589 20 140 51 564 198 514 216 543 367 542 82 364 80 111 210 366 462 515 108 207 436 623 485 536 58 347 39 678 6 699 129 581 125 401 150 490 93 565 532 621 153 350 27 398 308 504 175 212 21 75 193 644 35 553 19 515 291 527 258 683 413 530 468 525 74 514 208 472 …
Output: 46

Example 2:

Input: 355 1459 36 215 174 355 75 76 210 302 104 286 29 168 131 327 8 72 95 273 80 351 40 97 56 343 70 326 155 224 153 207 101 263 56 348 207 337 113 313 16 117 29 86 175 241 84 143 119 288 12 261 33 105 12 89 8 228 76 253 51 159 27 77 112 216 102 236 151 251 277 292 126 187 63 185 257 272 44 90 101 114 79 230 132 165 46 207 70 155 78 172 97 337 194 221 171 340 93 332 25 258 194 273 27 164 8 10 71 263 55 79 160 185 27 68 150 192 109 113 291 325 156 215 47 113 176 226 214 233 119 165 23 112 141 153 17 183 95 176 22 114 117 134 104 263 176 350 63 210 196 289 69 239 198 302 189 277 67 210 160 329 207 245 130 212 185 277 89 168 93 159 151 278 120 302 188 314 115 167 132 295 42 201 123 258 53 324 25 126 1 13 246 314 251 258 81 144 62 327 3 276 249 328 45 50 10 268 35 251 106 238 275 354 161 290 18 247…
Output: 1

Example 3:

Input: 719 1547 95 568 512 672 266 421 5 499 101 136 283 499 233 521 23 74 67 398 19 300 331 530 110 363 541 578 232 524 128 346 297 562 564 656 274 429 388 671 372 617 194 332 139 513 289 371 356 492 341 604 154 459 387 670 401 657 343 599 6 430 44 416 453 650 261 264 388 499 501 606 347 674 347 370 145 517 164 314 166 421 632 644 389 567 32 296 364 436 165 484 364 640 43 607 110 198 68 613 72 712 22 719 315 452 83 519 200 630 226 670 441 646 252 669 34 607 63 637 206 252 122 446 503 528 281 404 40 277 442 684 111 659 399 426 163 607 169 255 375 394 247 393 153 448 181 699 645 711 271 491 300 474 261 291 253 403 4 150 625 687 28 207 176 262 258 336 10 131 66 415 474 587 146 378 487 623 19 349 15 650 183 513 192 341 2 526 317 607 93 681 229 615 375 467 245 462 25 413 51 504 367 606 281 543 247 29…
Output: 11

Constraints:

1 <= n <= 799; 0 <= m <= 1598; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
Last tunnels of Curator - MEDIUM Coding Problem | CodeTikki