CT51218

The Pale Separate Camps

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Kabir inherited the observatory at the lily shoals of Padmore along with its curious bookkeeping system for corridors. Time to make sense of it. 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 <= 1816; 0 <= m <= 3632; 1 <= u,v <= n.

Example 1:

Input: 911 1964 102 182 391 746 409 704 198 256 102 759 59 394 195 240 623 886 365 836 452 743 146 179 104 269 568 796 371 659 711 848 155 651 592 706 430 862 156 783 189 449 164 637 313 701 127 878 415 711 370 824 153 803 241 323 179 675 311 658 443 728 179 790 524 823 197 798 229 574 315 416 528 634 296 853 311 679 43 524 326 862 116 875 479 627 82 814 285 398 197 460 203 852 161 721 319 569 318 591 136 817 533 622 535 553 240 684 32 514 327 524 236 684 194 229 400 762 173 827 16 503 146 574 201 766 498 823 104 171 435 567 63 880 415 757 185 792 422 497 255 718 606 800 387 435 713 874 25 600 399 692 334 700 112 714 204 728 149 420 53 828 158 673 642 775 54 300 86 469 260 593 32 398 118 669 94 536 825 909 233 861 228 532 172 188 197 468 158 335 49 274 177 605 80 428 449 688 614 794 507 671 541 6…
Output: 12

Example 2:

Input: 421 831 41 65 50 75 198 343 43 49 6 18 219 251 244 315 157 213 36 420 157 205 202 297 239 357 196 328 236 367 304 330 245 408 124 382 71 355 189 346 140 360 61 168 119 273 16 346 287 296 13 161 122 174 179 290 160 187 341 350 79 159 100 144 2 359 103 278 80 328 146 246 125 278 350 394 280 309 218 354 358 371 4 75 54 188 164 259 114 272 338 417 61 332 55 303 130 335 110 219 208 249 160 185 263 384 148 330 305 319 301 403 265 303 296 357 255 389 215 303 46 382 36 229 47 365 25 198 136 223 111 357 207 279 220 421 271 332 246 291 35 209 116 266 208 284 93 285 273 352 62 307 321 369 48 235 337 341 86 344 39 205 214 260 147 273 147 338 292 324 9 244 14 155 159 216 133 239 327 368 43 349 37 327 37 359 159 281 47 85 39 108 216 364 9 363 46 263 196 351 38 344 201 322 22 307 35 370 384 417 295 417 1…
Output: 5

Example 3:

Input: 1792 1241 658 1639 1518 1640 918 952 31 535 958 1333 226 1640 583 1197 1013 1433 83 443 208 352 557 1127 490 1317 51 1558 103 1237 53 1203 138 1670 1028 1428 27 1633 821 1403 522 792 1104 1636 379 1380 636 1677 1331 1670 865 1113 38 1020 16 505 260 314 1151 1726 549 850 37 460 360 656 1339 1531 50 113 859 1220 857 1763 188 1347 743 1378 1010 1759 1020 1507 804 1189 454 1688 208 779 1583 1734 1031 1373 928 1055 822 1147 77 425 143 1354 213 1090 823 1462 879 1215 1215 1366 274 1440 1354 1469 895 915 40 1491 89 740 69 124 1258 1740 387 556 303 489 1263 1789 1416 1591 304 1279 734 1212 458 1783 436 1326 956 1647 549 1695 553 757 38 951 121 1486 278 851 550 790 434 1338 461 499 122 1635 415 434 745 1032 690 1146 223 331 625 1174 890 1488 79 1784 210 1019 40 255 12 1183 55 942 1081 1571 1019 108…
Output: 594

Constraints:

1 <= n <= 1816; 0 <= m <= 3632; 1 <= u,v <= n.

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