CT47317

Aria's Polished Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The registry keeper Aria has been asked to inspect the delivered goods. On the desk lies a long table of roads readings. 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 <= 2070; 0 <= m <= 4140; 1 <= u,v <= n.

Example 1:

Input: 868 2272 634 783 223 434 687 859 234 243 458 472 141 626 22 434 41 419 43 298 454 831 130 538 77 603 676 868 666 707 465 533 186 341 677 817 533 825 434 554 355 610 181 218 485 566 550 563 73 396 223 795 395 403 655 807 210 555 27 805 69 836 267 798 56 791 188 302 788 857 220 823 15 708 125 318 69 612 714 824 210 332 89 162 353 426 127 621 142 627 274 559 325 333 112 299 491 742 64 727 57 319 41 148 17 55 537 626 350 710 138 360 113 327 7 641 370 691 46 588 354 506 55 561 401 482 150 266 127 723 845 861 252 707 473 658 138 303 46 576 19 834 237 267 136 567 225 541 29 36 20 294 103 273 382 503 91 485 82 312 775 839 191 511 430 735 359 487 341 713 479 652 376 642 290 595 24 264 237 817 568 779 782 787 426 507 330 832 332 699 412 753 547 852 64 494 137 575 641 672 122 399 7 522 229 415 124 71…
Output: 7

Example 2:

Input: 206 784 23 130 34 96 74 190 67 119 68 121 59 178 82 147 80 81 17 202 81 160 80 185 61 109 154 202 72 199 51 90 9 167 59 119 6 121 28 141 28 85 101 153 23 75 53 90 11 166 95 136 46 87 37 129 62 176 79 171 127 143 117 152 67 68 44 96 12 81 51 183 90 132 91 166 59 66 45 190 30 201 1 44 59 186 176 204 72 108 116 144 14 140 112 151 15 37 166 205 100 190 9 179 11 37 200 203 12 187 3 47 101 131 90 162 22 109 98 137 6 18 116 157 18 130 22 139 123 206 83 193 72 134 41 192 106 129 19 173 4 48 19 101 152 201 15 72 21 24 94 197 94 162 1 91 2 102 118 135 60 101 15 120 39 200 73 175 22 58 34 149 55 64 41 166 51 123 7 30 91 171 44 108 44 182 156 197 151 176 93 181 55 205 14 97 123 196 117 155 145 164 54 93 11 54 52 196 46 139 117 203 26 51 12 87 43 186 48 52 27 93 18 45 5 27 8 31 24 185 70 187 10 25 37 1…
Output: 1

Example 3:

Input: 709 1219 266 535 1 146 154 429 97 208 137 336 294 564 22 466 413 461 42 606 359 511 169 452 444 702 355 527 15 310 277 323 428 616 111 232 326 331 168 481 96 655 239 493 148 254 236 585 43 63 267 346 157 285 95 183 346 463 100 610 581 592 51 688 350 604 249 254 115 158 151 229 382 465 326 426 98 264 67 179 227 383 134 336 599 704 189 344 49 186 130 663 295 645 126 522 568 594 395 553 209 399 325 602 328 471 176 472 113 494 220 344 62 97 146 684 51 269 372 384 159 696 304 410 154 278 370 690 190 681 232 268 405 570 208 278 155 234 138 599 341 361 395 459 319 496 234 246 189 623 212 630 562 651 114 294 499 651 341 407 169 316 237 556 21 173 324 412 113 591 139 695 41 451 107 429 332 562 81 630 92 708 249 582 29 189 98 331 141 681 297 477 358 527 424 555 17 458 59 582 78 126 37 376 223 460 12…
Output: 25

Constraints:

1 <= n <= 2070; 0 <= m <= 4140; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
Aria's Polished Ledger - MEDIUM Coding Problem | CodeTikki