CT39836

Brass tunnels Separate Camps

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the ribbon falls of Cascade Vale pays by the answer, and Hope 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 <= 2581; 0 <= m <= 5162; 1 <= u,v <= n.

Example 1:

Input: 485 4094 194 207 316 406 253 454 110 282 89 369 28 252 107 349 5 377 220 453 53 478 27 31 145 190 165 475 70 140 17 345 163 214 222 260 85 378 92 425 275 335 57 263 195 445 116 155 122 382 64 127 38 349 237 326 252 377 228 232 212 367 342 410 33 122 91 433 88 150 187 444 427 457 194 281 256 350 254 359 114 133 10 220 108 289 111 324 389 458 228 429 376 389 43 169 119 298 124 257 41 434 218 453 175 317 50 124 5 342 318 367 231 382 148 409 278 473 103 341 35 359 229 288 28 72 68 383 72 365 130 201 39 90 316 327 113 466 61 87 359 388 63 360 372 375 249 358 31 182 55 138 11 181 141 368 34 394 124 370 197 483 161 427 226 229 25 308 399 480 98 433 111 484 131 261 36 86 15 226 120 312 261 405 36 65 50 116 122 377 157 234 90 423 119 182 136 305 127 290 141 296 133 207 67 95 286 289 227 229 3 65 51…
Output: 1

Example 2:

Input: 1087 1190 21 1029 9 631 676 744 65 350 520 772 270 621 62 525 385 716 150 220 443 589 202 315 192 251 143 287 112 506 114 591 446 687 31 609 772 943 441 748 199 412 3 261 17 367 449 984 133 173 545 933 472 602 299 475 112 1068 154 354 197 751 436 650 207 674 91 695 360 829 829 927 312 476 228 587 914 986 52 957 641 651 59 840 167 701 211 464 785 854 423 1015 13 752 453 740 353 977 171 292 22 791 356 1060 832 875 492 1071 63 897 214 922 807 890 159 412 23 534 345 708 838 852 496 823 157 879 103 112 90 804 210 594 840 873 134 833 66 420 650 664 50 403 166 633 274 498 186 830 783 1033 376 821 118 967 992 1037 300 774 334 1045 256 804 446 1084 100 816 5 826 337 627 258 701 1 266 537 687 271 839 529 678 329 606 91 679 331 1066 104 498 632 819 279 420 421 935 86 867 97 362 197 607 257 453 21 475…
Output: 137

Example 3:

Input: 847 2763 586 810 358 708 259 606 108 664 627 659 141 788 312 425 422 821 358 467 153 262 128 303 131 600 51 187 335 777 134 716 18 239 115 809 5 698 486 735 18 622 131 310 259 380 306 577 659 765 97 336 163 486 404 662 353 564 536 788 226 294 350 427 254 363 317 674 178 492 147 694 214 441 193 209 10 451 88 363 35 625 215 281 159 822 694 698 648 761 338 346 331 379 526 805 514 713 22 720 156 644 91 567 42 130 43 240 93 327 13 101 327 632 35 503 173 513 73 548 272 456 145 449 299 300 518 658 296 771 483 833 109 258 136 774 310 376 439 484 140 771 245 249 206 516 817 837 456 507 39 700 169 759 479 620 439 529 156 706 25 181 710 785 221 332 138 587 234 263 182 360 607 692 114 625 178 613 73 468 243 803 312 653 8 672 250 489 164 729 65 457 548 623 151 355 501 620 371 560 303 660 480 712 353 60…
Output: 3

Constraints:

1 <= n <= 2581; 0 <= m <= 5162; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.