CT43617

Zoya's Separate Camps Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the alabaster quarry of Whitestone, Zoya the factor keeps careful count of the canals. assign crews to the morning shifts, every figure matters. 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 <= 1275; 0 <= m <= 2550; 1 <= u,v <= n.

Example 1:

Input: 999 1863 556 597 308 530 593 697 239 594 40 663 760 991 151 992 601 615 226 535 569 605 673 940 181 404 514 686 750 751 187 535 554 609 800 807 41 646 597 710 271 757 695 773 90 151 169 714 52 766 97 293 71 492 377 896 543 617 195 251 432 489 382 719 384 974 683 842 58 181 96 584 204 898 646 707 305 560 547 623 104 237 192 625 145 709 241 962 461 467 62 436 103 961 109 323 515 625 251 339 314 398 24 593 328 436 134 800 736 974 654 712 168 928 99 545 171 994 228 605 871 925 58 140 643 905 237 339 452 608 446 477 387 490 249 740 465 606 218 567 581 964 155 600 542 681 820 929 11 19 224 327 305 760 191 558 145 674 259 855 144 483 214 258 564 931 229 356 328 850 549 603 786 827 332 547 462 606 671 814 346 500 497 647 281 283 294 974 421 855 6 172 539 773 363 547 633 772 124 327 799 979 86 952 …
Output: 29

Example 2:

Input: 1071 1450 222 570 10 822 27 424 6 356 154 278 99 170 801 942 230 860 550 778 813 840 269 1013 116 219 66 917 65 584 195 784 195 503 15 835 298 630 814 948 23 327 348 882 508 668 175 944 85 788 172 526 395 473 5 430 131 372 494 757 796 997 144 374 840 990 531 638 441 701 253 1050 493 949 349 579 330 442 589 672 58 98 421 791 392 523 24 658 79 482 227 257 611 1011 440 978 339 440 297 794 473 1034 436 929 116 981 489 813 681 999 165 993 902 1045 313 644 165 353 64 368 219 964 323 393 579 898 822 1000 254 302 216 760 396 695 117 241 854 1040 111 232 816 1002 684 1032 319 1051 693 860 435 580 107 900 362 673 509 931 633 965 236 317 901 1022 597 1058 295 624 120 1071 66 752 520 716 375 815 161 381 296 584 75 360 819 952 535 737 420 914 205 355 303 759 759 859 386 973 211 1042 955 1002 207 731 39…
Output: 83

Example 3:

Input: 548 1539 159 285 24 29 131 349 39 240 34 254 192 510 160 537 135 236 163 514 326 380 225 373 47 291 209 421 96 338 501 525 149 211 463 485 119 162 43 453 312 407 139 340 236 398 233 404 290 444 282 286 109 400 300 494 33 312 186 293 355 417 252 259 384 461 23 455 291 371 438 491 113 182 361 492 348 430 58 231 321 445 169 493 221 260 86 310 95 210 76 517 9 172 445 547 23 538 269 274 181 505 364 452 92 524 260 341 12 287 72 189 97 368 55 331 170 400 389 483 156 452 239 291 78 175 20 211 252 510 484 523 12 275 286 463 66 300 302 395 6 184 416 462 141 485 243 529 10 199 119 172 291 503 337 374 219 442 40 161 280 474 170 280 21 197 346 451 106 299 475 537 205 410 75 183 253 282 204 348 65 149 49 179 35 502 137 497 39 472 13 164 249 304 214 381 381 548 347 368 31 105 44 473 105 109 137 349 307 3…
Output: 2

Constraints:

1 <= n <= 1275; 0 <= m <= 2550; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
Zoya's Separate Camps Ledger - MEDIUM Coding Problem | CodeTikki