CT53659

The Quiet routes of Vesper

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the sulphur springs of Brimstone close for winter, Vesper must finish the routes ledger - one figure at a time. 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 <= 2146; 0 <= m <= 4292; 1 <= u,v <= n.

Example 1:

Input: 1159 2022 440 864 520 643 146 928 257 333 1110 1120 43 574 40 681 410 1127 484 822 22 604 658 885 73 679 428 1077 50 488 472 930 91 596 516 830 734 1045 428 1105 640 857 927 1025 504 837 791 1133 377 961 295 322 355 397 55 700 19 685 750 758 461 624 362 925 395 464 103 148 165 217 293 866 567 1019 36 97 56 675 742 853 40 1022 571 847 784 820 273 786 677 1151 7 809 97 402 380 827 237 823 202 875 375 421 318 341 58 699 141 728 611 1156 520 598 4 238 788 1150 213 1023 694 747 534 1104 512 1013 791 1132 677 934 460 637 835 1007 304 1061 103 143 551 1049 107 404 229 543 64 923 105 1133 1085 1095 225 640 53 922 433 1100 619 850 118 156 171 985 409 897 997 1081 78 202 271 687 38 813 127 338 481 682 818 921 494 1137 158 1018 257 469 254 1028 182 562 419 775 431 479 120 697 254 1106 208 768 390 448…
Output: 31

Example 2:

Input: 469 2876 236 466 153 393 118 192 92 163 10 336 321 408 108 152 394 416 108 222 343 462 264 397 141 297 203 422 385 463 54 448 33 390 166 403 284 298 28 377 358 383 92 405 412 442 77 244 226 414 81 374 41 212 102 164 265 449 244 427 13 397 56 237 37 389 450 452 4 141 157 303 226 453 255 258 211 227 157 230 43 323 200 400 11 29 38 219 45 279 103 246 147 265 50 77 45 225 28 260 89 156 255 376 309 312 344 407 188 246 108 197 56 233 118 305 76 344 274 392 69 149 241 398 350 390 209 223 170 454 119 370 349 384 239 395 21 396 147 445 168 228 18 257 447 453 14 145 90 235 17 268 331 425 40 435 17 171 35 78 130 249 109 376 126 292 246 350 74 445 54 215 127 284 79 131 12 30 273 440 88 278 24 463 7 383 83 258 195 332 226 335 110 298 269 438 260 394 223 463 120 221 32 434 147 278 187 262 26 352 51 453 …
Output: 1

Example 3:

Input: 366 1025 100 347 97 293 262 299 199 339 38 148 10 67 22 274 113 347 63 285 129 150 32 127 241 289 45 72 308 343 141 247 89 220 95 198 121 139 214 356 108 118 208 307 72 86 45 132 243 256 232 344 221 299 125 238 3 215 44 187 36 247 254 269 128 260 90 265 293 294 335 364 54 95 13 56 21 319 117 246 179 264 211 290 143 283 185 350 91 346 186 346 91 274 81 168 5 66 169 241 95 304 27 252 2 124 340 363 164 253 26 99 197 232 266 344 175 339 215 246 250 300 86 247 114 273 156 185 237 299 93 242 35 149 115 331 102 137 63 106 1 279 49 358 86 94 27 153 81 84 51 74 90 124 207 217 240 321 207 273 242 264 37 304 121 133 101 196 70 295 89 162 100 205 96 223 79 289 9 262 199 264 54 105 139 172 20 161 178 271 207 311 47 135 190 343 91 273 115 284 344 349 28 304 9 112 11 41 8 364 71 290 70 171 281 317 99 341…
Output: 2

Constraints:

1 <= n <= 2146; 0 <= m <= 4292; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
The Quiet routes of Vesper - MEDIUM Coding Problem | CodeTikki