CT33687

The Smoky corridors of Admiral

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the quartz ridge of Glimmerfell, someone must reorganize the archive shelves. This year the task falls to Admiral, armed only with the corridors register. 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 <= 1603; 0 <= m <= 3206; 1 <= u,v <= n.

Example 1:

Input: 260 2368 42 61 108 133 130 131 48 133 195 244 175 176 152 220 68 247 62 79 40 187 3 158 95 147 99 240 67 113 134 187 228 242 68 163 74 142 10 187 16 245 157 208 8 248 120 139 131 228 42 249 207 231 115 196 8 24 189 247 91 158 40 85 147 177 178 201 30 181 197 205 63 247 21 74 167 195 51 260 140 154 183 234 53 221 27 238 93 221 173 230 26 233 128 167 22 29 205 242 107 225 181 219 45 166 130 251 86 128 7 30 124 177 106 251 209 253 107 109 51 252 38 130 11 135 91 169 13 158 116 145 58 258 152 203 12 251 4 192 9 142 118 255 157 234 144 253 193 233 29 254 25 192 77 195 1 129 85 208 47 227 197 224 113 131 128 169 16 146 24 223 149 246 22 76 60 126 88 210 27 130 109 233 114 193 49 81 100 130 73 156 167 243 214 252 86 249 36 95 94 256 112 182 4 254 122 153 88 149 90 167 7 209 34 240 11 91 20 191 8 …
Output: 1

Example 2:

Input: 360 2949 51 106 36 305 30 81 13 191 300 335 106 159 212 356 110 244 39 239 181 204 11 253 56 121 78 167 44 315 172 231 118 175 10 44 40 350 188 212 59 60 307 341 9 22 43 222 103 123 128 300 147 306 265 347 293 321 197 357 238 353 183 195 266 289 92 128 20 322 1 9 9 164 229 253 159 252 70 224 84 350 314 334 36 240 14 49 324 326 95 99 39 302 186 259 29 125 173 287 63 160 141 355 310 334 19 303 89 163 283 285 115 349 198 232 10 223 155 267 53 181 161 213 80 208 59 92 145 232 245 338 172 352 25 44 326 342 61 340 213 305 49 107 136 279 249 300 164 213 158 195 25 145 45 317 41 266 111 298 179 219 1 252 47 217 15 250 196 214 67 339 25 297 25 168 173 257 21 128 217 249 8 190 81 199 145 302 56 338 106 195 104 156 24 111 216 235 18 110 103 235 112 219 67 156 43 318 147 275 117 187 67 359 85 212 77 1…
Output: 1

Example 3:

Input: 1397 3121 381 1395 757 980 243 938 141 600 1242 1273 152 326 1159 1330 1242 1382 392 992 524 1186 593 880 205 823 741 1326 764 816 75 991 82 357 719 725 237 1348 468 1149 20 967 496 976 910 1197 372 1047 165 338 65 986 930 1299 1048 1200 483 666 550 1160 843 1009 250 555 648 1115 352 367 37 1095 600 1242 848 1024 243 511 615 1210 98 749 131 442 295 1316 984 1220 372 1168 382 1152 751 802 591 1246 231 1131 93 266 594 1205 931 1033 554 898 603 1168 250 252 252 1066 599 728 696 1088 880 1345 568 1253 687 1105 328 800 649 1179 57 677 527 1223 212 904 759 1103 712 867 420 1010 21 1246 312 420 458 567 150 1309 292 945 405 808 45 1177 339 417 17 1210 879 1317 1007 1213 6 1294 248 356 998 1084 435 726 666 1309 93 1279 174 867 36 574 1283 1296 55 85 379 1394 1000 1359 574 605 924 1146 87 758 165 60…
Output: 21

Constraints:

1 <= n <= 1603; 0 <= m <= 3206; 1 <= u,v <= n.

Loading...
Test Cases:No test cases
No test cases available.
The Smoky corridors of Admiral - MEDIUM Coding Problem | CodeTikki