CT38814

The Separate Camps at Glimmerfell

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the quartz ridge of Glimmerfell, Isha the scribe keeps careful count of the canals. Decode the foreman's shorthand notes, 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 <= 1379; 0 <= m <= 2758; 1 <= u,v <= n.

Example 1:

Input: 615 1182 5 468 366 522 393 469 122 390 51 75 69 264 158 614 78 393 345 375 213 589 171 404 259 430 362 378 41 435 170 409 26 603 6 475 406 523 17 473 281 321 153 158 181 565 58 149 88 320 333 425 501 586 30 55 60 172 305 537 344 553 327 453 22 77 96 415 111 487 96 128 54 429 96 558 115 589 119 230 76 96 299 433 186 520 71 423 71 269 5 609 135 493 13 238 283 529 165 393 144 306 42 374 275 308 217 293 57 59 377 477 64 377 289 500 49 368 270 605 135 284 151 179 240 517 246 310 337 592 192 275 37 302 263 500 8 247 302 303 175 598 42 142 530 558 149 490 444 557 364 381 84 422 37 315 149 242 77 144 322 608 491 542 120 386 310 454 246 402 185 310 219 225 361 543 150 513 152 185 36 579 206 533 35 465 180 421 113 463 357 589 187 362 338 564 157 341 61 227 4 56 244 440 220 558 131 248 9 517 192 341 …
Output: 14

Example 2:

Input: 307 636 174 178 97 213 76 158 116 138 31 226 267 295 164 181 57 105 231 282 73 307 156 232 177 306 53 87 128 177 142 279 34 295 35 188 94 124 42 46 104 108 117 290 136 168 23 274 63 301 157 249 75 141 256 304 93 199 229 266 75 240 172 177 195 300 155 269 35 78 55 204 123 134 16 236 91 208 111 144 151 160 178 183 194 206 80 282 30 43 114 270 253 277 7 184 23 46 43 56 7 266 126 178 60 193 73 171 51 202 282 285 31 76 122 238 151 246 115 130 248 257 99 193 152 263 79 163 64 266 111 304 29 276 116 180 90 155 53 153 172 241 81 175 116 150 68 168 30 264 245 284 2 169 44 83 31 244 59 223 10 137 138 205 81 106 203 287 9 230 133 210 32 301 113 215 283 304 150 211 165 306 181 216 22 217 123 260 139 293 117 247 53 54 71 304 199 207 153 154 109 216 83 225 100 138 5 306 17 291 30 301 180 182 77 210 53 2…
Output: 4

Example 3:

Input: 463 1306 33 227 85 333 74 411 37 81 222 418 60 176 172 457 11 376 382 425 205 395 440 451 170 293 81 167 385 403 188 277 231 463 231 364 87 459 22 209 36 276 264 383 149 420 60 198 54 71 302 451 146 245 245 402 122 316 293 308 165 441 323 378 246 392 29 421 34 453 89 403 253 438 296 449 310 350 62 209 287 328 26 400 190 268 389 427 304 349 208 281 106 402 41 399 248 350 44 261 6 273 153 257 49 400 172 357 13 382 332 337 35 245 63 215 122 371 107 182 242 280 95 216 266 393 243 315 114 412 207 366 17 445 222 374 284 327 35 154 294 299 37 309 82 372 208 437 159 345 1 96 276 311 232 234 162 164 301 375 115 246 60 134 63 178 363 372 245 333 244 354 181 365 266 402 141 446 159 216 1 393 212 323 304 329 138 243 236 251 32 146 344 463 126 416 14 177 57 105 141 450 191 458 224 416 255 326 117 351 8…
Output: 3

Constraints:

1 <= n <= 1379; 0 <= m <= 2758; 1 <= u,v <= n.

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