CT43314

The Galeholm Separate Camps

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the zephyr cliffs of Galeholm pays by the answer, and Eklavya 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 <= 1499; 0 <= m <= 2998; 1 <= u,v <= n.

Example 1:

Input: 922 2949 86 185 177 584 88 469 44 194 112 119 160 560 376 521 867 898 43 175 736 840 443 862 31 246 220 360 374 482 213 407 161 403 10 836 44 115 415 819 316 318 416 432 22 692 140 730 621 737 321 462 88 531 250 412 324 595 116 137 709 904 38 529 38 377 212 776 505 698 76 628 502 840 250 798 816 874 99 266 231 387 164 483 19 611 184 210 391 480 427 667 364 440 162 284 393 916 51 495 225 403 454 799 640 761 78 684 162 483 109 355 13 332 172 213 687 711 191 845 743 761 181 403 92 500 127 573 298 440 49 497 415 675 294 828 373 597 354 597 497 898 480 741 31 441 193 407 346 368 137 407 141 836 678 881 468 549 234 493 121 619 80 126 6 922 384 752 222 650 512 561 5 422 583 711 271 396 7 39 591 892 226 820 17 594 510 883 338 922 555 598 149 722 226 431 479 719 97 759 202 752 44 584 442 648 286 82…
Output: 4

Example 2:

Input: 1195 2662 132 1137 264 475 382 470 277 342 215 1010 469 1138 355 837 184 553 195 1105 527 1036 104 727 216 616 909 1006 652 1169 32 1034 142 376 1063 1132 51 896 1007 1124 981 1081 542 1064 682 1055 422 852 475 648 122 502 471 1100 207 476 476 756 1028 1116 305 915 642 1038 720 787 497 551 147 367 90 535 386 1148 1002 1086 115 676 222 549 360 980 622 1120 122 799 54 1042 736 1065 20 730 429 1107 215 638 1117 1188 69 930 585 1057 439 579 51 282 185 333 466 722 82 131 856 966 634 1146 633 1181 434 448 204 842 711 910 392 939 1049 1161 491 773 446 1124 527 585 43 546 165 672 876 1076 167 945 211 243 570 1071 27 36 359 1146 256 735 252 380 572 829 479 853 499 1103 335 856 445 851 68 739 618 951 1011 1185 118 930 463 946 971 1028 630 741 356 1155 1050 1106 117 126 293 713 265 319 424 756 906 10…
Output: 14

Example 3:

Input: 264 2311 56 200 36 38 144 156 126 209 124 212 22 23 125 135 215 219 36 254 159 193 47 152 43 139 106 195 75 194 179 212 10 49 113 242 119 218 170 171 54 86 25 145 78 190 52 209 149 211 89 191 184 207 54 204 25 61 129 228 154 219 53 215 87 230 78 221 164 207 58 166 156 253 96 258 10 19 88 102 122 191 111 130 24 102 241 252 105 178 185 219 81 150 41 119 45 246 29 74 32 118 81 199 73 178 108 128 107 174 142 253 134 174 161 207 63 115 118 194 82 175 73 154 116 193 35 36 170 232 189 259 124 223 161 215 127 221 85 195 119 233 114 262 23 53 85 132 99 177 86 229 40 178 19 73 41 149 5 9 78 95 62 180 39 259 83 214 194 245 89 185 26 113 107 253 135 173 93 165 154 212 84 106 151 193 27 185 20 30 20 176 164 255 69 256 120 175 11 102 163 205 20 112 167 216 121 233 156 183 49 253 80 90 175 198 55 149 137…
Output: 1

Constraints:

1 <= n <= 1499; 0 <= m <= 2998; 1 <= u,v <= n.

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