CT32476

The corridors at Bluehollow

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the indigo vats of Bluehollow, Quartermaster studies rows of corridors entries. One clean number will settle the guild's oldest argument. 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 <= 1345; 0 <= m <= 2690; 1 <= u,v <= n.

Example 1:

Input: 150 12 59 79 50 118 110 117 40 102 40 93 29 120 1 14 38 96 51 123 20 66 82 138 61 130
Output: 138

Example 2:

Input: 1139 1261 214 1035 146 958 394 450 221 763 466 918 490 915 559 771 606 910 605 664 1055 1088 241 378 12 685 411 867 715 1089 571 773 370 929 508 905 134 576 79 572 294 640 750 1080 409 911 911 921 578 688 485 1088 975 1007 841 891 256 1016 482 1072 12 450 72 337 974 1106 501 654 408 700 296 405 62 228 204 556 498 515 863 939 500 716 104 329 370 548 404 670 395 811 197 247 87 852 481 506 752 919 536 814 221 893 260 832 524 685 14 522 170 1077 440 1027 615 898 448 519 292 606 341 861 686 985 72 101 21 996 349 672 530 825 75 825 617 885 713 737 254 415 20 754 131 1127 217 314 458 782 109 844 150 784 913 987 31 686 80 360 202 1055 154 849 484 564 391 901 978 1124 186 312 51 521 673 679 451 680 492 521 368 420 84 1037 759 857 473 1072 548 1017 107 1032 233 565 328 1124 186 639 82 291 2 992 161 …
Output: 147

Example 3:

Input: 196 2434 84 85 66 131 55 106 42 177 49 124 12 176 94 168 80 124 106 114 121 175 147 174 26 95 101 196 106 161 90 102 122 177 13 39 27 155 41 187 146 171 20 27 107 143 172 195 64 93 74 173 29 106 50 126 85 134 110 120 13 170 25 162 147 170 1 18 151 160 29 176 46 182 47 121 101 104 87 154 19 102 67 84 91 125 19 101 86 117 84 100 47 73 96 183 15 27 121 146 19 34 10 20 32 107 83 96 38 179 2 48 116 153 63 184 159 163 108 148 43 195 14 157 130 188 34 71 33 102 13 37 18 154 115 188 10 26 16 181 51 81 12 81 51 174 27 28 57 183 55 92 74 178 55 87 8 103 10 29 38 43 112 196 101 124 28 55 63 180 116 139 107 154 77 169 35 68 130 138 21 144 137 152 42 160 90 151 106 115 32 163 63 89 100 194 137 165 118 189 39 138 103 166 88 185 128 175 41 169 61 76 130 142 26 166 131 139 92 119 40 134 7 65 102 109 2 85 …
Output: 1

Constraints:

1 <= n <= 1345; 0 <= m <= 2690; 1 <= u,v <= n.

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