CT30915

Jace's Gleaming corridors

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the moonlit lagoon of Selene, Jace records each corridors in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1656; 0 <= m <= 3312; 1 <= u,v <= n.

Example 1:

Input: 1517 548 771 818 452 1345 262 390 23 1133 130 198 63 258 275 1277 1271 1423 1405 1497 227 1169 558 1329 126 1065 185 833 421 1142 521 1308 610 969 31 448 1037 1455 819 1206 194 995 486 769 657 982 1144 1222 845 983 551 559 655 1057 240 524 1181 1457 333 781 372 850 583 1152 287 428 327 1428 20 1023 346 566 368 482 198 532 492 1504 233 1289 92 240 690 778 738 1288 41 522 113 1016 582 928 821 1374 368 567 451 998 739 826 224 1317 632 664 1119 1362 610 1404 840 1044 358 1283 202 418 267 290 389 1470 535 1414 364 1216 822 835 359 968 580 811 720 1288 478 1027 1170 1210 1048 1191 515 1034 82 1266 537 773 398 1057 255 711 501 1297 436 933 8 1243 159 361 269 875 390 1098 316 1002 175 923 330 994 1287 1335 674 1313 1108 1309 278 1447 973 1232 1 627 377 668 868 1477 224 865 695 1087 184 1242 323 52…
Output: 969

Example 2:

Input: 1509 537 1009 1347 1269 1479 316 560 1 376 1142 1288 342 564 1292 1476 350 1187 68 1499 918 925 65 461 893 1213 842 897 1215 1273 233 1234 45 1428 405 1047 1354 1468 319 373 835 1094 618 981 687 1166 598 1254 804 882 287 450 508 587 428 1481 164 1437 481 496 467 468 288 960 112 662 800 1381 790 1298 610 1008 1229 1363 878 1281 720 1496 789 1005 548 591 71 584 1231 1496 176 1022 171 1352 971 1207 611 690 1028 1267 540 882 390 924 917 1297 791 925 606 1233 822 1418 189 979 523 1204 748 909 1127 1419 842 1196 314 742 1063 1286 134 670 101 1367 94 403 687 1369 324 1286 1187 1280 443 1265 1089 1142 175 1104 547 1317 775 1497 408 644 569 861 210 1429 744 1027 395 645 1292 1474 368 1092 547 1359 34 340 1182 1201 312 521 948 1050 1024 1445 113 700 78 102 454 1006 945 1331 257 739 418 1151 997 1227…
Output: 972

Example 3:

Input: 226 307 9 157 60 155 120 183 12 93 45 218 89 192 126 184 47 201 132 216 173 212 108 149 137 148 99 136 4 145 116 206 68 212 7 20 115 163 17 35 52 136 101 147 82 188 56 182 65 217 65 93 222 225 43 198 113 192 71 144 99 113 45 175 26 98 9 36 38 226 53 226 24 182 78 135 46 195 24 223 3 193 132 168 19 51 18 138 82 171 46 179 51 154 6 37 53 187 106 110 9 165 47 106 47 72 53 74 103 195 48 224 87 224 19 105 160 161 134 198 34 50 11 60 55 160 86 133 71 223 70 158 134 166 10 186 32 60 4 188 92 167 65 90 132 201 12 117 86 205 123 156 1 74 47 143 149 210 100 198 106 152 44 129 97 137 97 221 25 73 18 175 28 160 118 195 121 131 102 123 166 207 84 87 147 170 119 151 47 116 62 159 102 154 50 219 138 172 171 225 152 179 100 127 99 216 168 219 44 97 97 225 75 137 71 162 101 180 43 59 43 116 13 76 156 198 6…
Output: 13

Constraints:

1 <= n <= 1656; 0 <= m <= 3312; 1 <= u,v <= n.

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