CT48335

The Separate Camps of the Faded canals

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the eel marshes of Slitherwick; Freya weighs the day's canals manifests and starts the calculations. 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 <= 3094; 0 <= m <= 6188; 1 <= u,v <= n.

Example 1:

Input: 906 3423 805 820 208 422 15 94 685 873 202 823 241 838 535 656 292 441 285 372 31 719 72 490 727 853 391 470 743 852 581 901 192 534 183 203 111 398 61 744 447 611 769 788 443 612 496 559 115 682 596 818 528 867 370 447 394 412 40 50 40 227 500 884 189 688 137 590 171 393 607 859 37 367 247 894 384 449 401 904 79 571 387 556 499 625 559 794 85 480 138 835 6 717 548 595 628 751 451 474 382 656 57 666 184 657 63 641 688 822 707 847 105 569 185 503 514 833 129 664 23 302 797 801 164 709 415 762 413 808 370 678 272 769 499 906 145 683 744 853 520 778 311 547 451 578 253 896 623 725 32 864 16 373 68 468 610 664 215 737 377 873 123 635 184 245 372 600 5 199 285 484 193 665 498 693 446 610 251 829 144 170 194 448 54 215 234 491 350 683 57 814 445 678 43 768 347 732 119 573 592 604 129 165 283 564…
Output: 1

Example 2:

Input: 2699 5914 1360 2276 1012 1992 252 318 1350 2535 319 700 852 2457 380 1514 320 1951 174 1585 829 2567 374 486 1435 1725 1182 1226 1143 2564 1005 2678 1823 1969 1030 1407 2080 2344 24 630 1391 1606 1819 1865 1612 2085 330 1298 1650 1679 49 788 959 2264 802 2477 1945 2475 1619 2361 1783 2281 276 330 1566 2485 732 2682 939 2691 1152 1443 2205 2584 986 2148 1240 1585 703 888 1037 2665 741 1129 2446 2637 912 1459 1116 2423 1900 2351 295 2184 1173 2042 601 2637 21 2199 1037 1187 879 2245 144 2445 865 1641 314 1390 1689 2333 119 955 323 971 79 1303 1550 2595 1545 1897 669 2433 572 1890 854 1015 1165 1915 2239 2471 1746 2081 1016 2330 642 2237 249 1390 904 2013 504 869 1436 1563 1536 2051 174 744 918 2183 621 2506 1280 2547 907 1791 977 2413 113 1882 1323 1941 1091 1525 415 1326 36 354 2335 2598 25…
Output: 28

Example 3:

Input: 1888 3381 1283 1467 1116 1381 1022 1472 113 1745 678 1796 953 1796 506 1312 307 1293 631 952 75 1593 217 1687 394 453 866 1113 552 1685 259 1365 711 954 15 680 397 1021 283 1502 701 1125 79 1037 450 1740 259 919 1566 1839 261 438 506 633 241 576 1184 1391 115 494 1093 1632 370 1213 537 1502 899 1429 336 964 1116 1800 1132 1695 1089 1814 1171 1742 427 1755 811 1236 445 1442 661 874 984 1675 492 918 367 653 213 1638 937 1765 359 752 225 1500 678 1221 453 1076 721 1203 12 1514 47 336 56 423 1375 1633 1800 1876 405 861 136 1762 758 1625 133 539 917 977 344 1829 849 1680 27 1311 228 1132 1291 1355 929 1198 361 963 414 1593 445 814 868 1504 1042 1648 679 1032 1131 1651 138 1522 16 315 516 1267 137 1016 579 781 1619 1650 491 1379 999 1124 408 1443 414 1254 787 1453 1690 1716 1212 1645 204 778 177…
Output: 48

Constraints:

1 <= n <= 3094; 0 <= m <= 6188; 1 <= u,v <= n.

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