CT44790

The Separate Camps of Greystone

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the shale slopes of Greystone. Petr spreads the roads records across the table and picks up a sharp pencil. 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 <= 2113; 0 <= m <= 4226; 1 <= u,v <= n.

Example 1:

Input: 540 3019 129 423 149 169 301 508 177 502 118 177 181 490 10 224 361 453 125 479 196 272 61 190 403 415 191 437 9 396 238 356 49 399 19 235 289 407 126 384 178 355 47 225 408 505 244 535 79 520 309 329 408 508 300 524 86 274 329 394 13 324 383 453 312 511 43 247 306 405 33 221 62 275 149 255 200 313 431 538 38 312 330 343 328 463 420 528 186 406 51 78 167 355 35 524 122 134 29 421 209 248 18 148 291 527 114 375 151 430 74 494 112 284 75 363 211 244 136 259 159 396 131 298 16 489 58 168 10 100 339 371 41 339 283 329 32 165 178 301 164 517 65 316 303 441 188 453 12 95 11 450 208 392 378 443 113 445 81 178 31 448 144 289 341 465 159 285 341 394 298 372 143 281 156 298 300 489 131 492 263 300 198 413 254 528 482 505 43 222 128 305 9 353 136 234 34 321 16 521 266 373 120 478 29 404 101 268 229 4…
Output: 1

Example 2:

Input: 386 1722 157 179 132 340 228 298 300 349 27 243 281 384 77 253 96 234 131 247 174 304 2 272 205 237 94 380 141 232 65 216 65 326 215 218 21 309 23 132 114 377 72 157 44 116 234 319 30 83 106 108 102 173 130 335 72 316 204 259 168 307 22 41 241 270 302 330 42 225 184 335 66 193 117 229 129 183 215 288 32 138 27 76 159 329 100 305 25 232 59 190 15 164 180 214 152 293 184 348 27 194 78 339 262 319 12 224 2 173 103 227 85 350 127 295 84 302 219 264 19 233 154 299 179 223 234 329 35 123 227 343 44 369 233 336 239 284 13 230 236 295 220 369 73 144 221 359 28 281 276 379 171 320 196 326 82 386 129 372 203 284 225 228 92 98 20 187 273 281 249 280 26 375 125 130 323 351 39 72 272 375 229 306 221 284 60 176 50 291 19 309 92 357 139 315 252 384 150 206 121 227 155 363 141 160 299 326 237 272 67 133 2…
Output: 1

Example 3:

Input: 2082 3602 581 981 222 838 1055 1602 240 1238 967 1826 911 1386 134 997 13 1225 2043 2044 1398 1617 1085 1493 737 1919 644 1906 1520 2019 883 1758 1255 1355 562 1170 318 2076 649 1881 1917 1967 802 1827 1013 1278 688 1442 1078 1305 71 235 382 1526 654 1239 483 1390 82 350 38 1836 370 409 567 1020 63 1309 491 1646 903 980 270 1837 1180 1736 431 1129 1 66 569 1398 327 1759 934 1620 290 1533 743 1391 1437 1920 1286 1455 1888 1967 889 1510 980 1431 980 1280 1938 2054 60 392 757 1432 38 921 31 2020 703 1959 550 1042 911 1704 1353 1954 605 718 329 2001 667 1795 371 1954 56 1049 215 1695 969 1108 527 1587 954 1112 55 413 240 529 518 1567 545 2057 409 1432 524 2058 1346 1601 333 1262 311 2042 1776 1966 931 1610 184 1538 155 1555 289 1436 1065 1180 1094 1159 1484 1955 562 1087 854 867 281 758 112 11…
Output: 80

Constraints:

1 <= n <= 2113; 0 <= m <= 4226; 1 <= u,v <= n.

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