CT38591

June's routes Separate Camps

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the lantern district of Glowfen; June weighs the day's routes manifests and starts the calculations. 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 <= 1655; 0 <= m <= 3310; 1 <= u,v <= n.

Example 1:

Input: 69 1631 23 46 8 67 7 25 32 53 10 67 56 60 38 68 40 57 45 69 39 58 1 45 45 55 20 67 3 44 3 9 2 36 3 68 33 35 15 66 45 48 36 58 15 17 18 48 25 41 57 58 5 47 46 57 43 56 19 58 18 40 10 30 11 66 23 36 23 33 9 17 13 39 3 69 10 56 20 27 16 38 15 62 5 68 8 57 31 47 21 35 14 55 5 11 11 22 14 16 15 49 2 8 1 17 6 33 9 48 48 57 8 54 20 32 6 7 24 62 10 59 19 42 43 45 7 26 47 60 4 27 9 41 47 54 7 13 21 30 39 49 30 55 7 42 12 13 6 40 28 50 16 52 2 52 39 40 29 56 10 65 22 40 19 29 2 10 13 58 28 68 19 43 42 52 4 58 1 37 4 50 28 52 28 67 16 42 1 25 52 55 36 45 29 32 31 50 50 64 9 65 8 46 64 68 45 66 29 52 32 54 27 57 64 66 26 65 9 20 23 67 54 68 34 67 50 66 4 12 3 16 3 26 7 22 21 27 12 43 18 68 21 42 1 4 8 60 13 25 11 39 62 69 6 43 34 64 46 56 26 45 34 62 26 47 11 63 17 40 46 55 1 50 34 44 19 35 43 51 17 4…
Output: 1

Example 2:

Input: 24 48 3 18 9 10 7 17 10 19 1 4 4 22 8 19 10 20 17 23 8 22 14 21 15 17 3 11 9 18 6 11 6 17 14 20 10 24 8 21 20 23 1 22 5 14 4 5 11 12 12 17 14 18 8 11 12 14 5 17 15 24 7 22 11 24 20 22 20 24 8 18 14 24 5 9 10 22 1 16 4 19 12 23 5 15 19 22 2 5 4 8 7 16 1 23 6 21
Output: 2

Example 3:

Input: 1492 1281 313 518 679 847 685 1045 553 983 675 1297 114 1036 585 899 925 1392 735 741 179 1072 684 1268 70 1049 943 1292 1227 1331 716 989 914 1116 388 689 494 917 610 875 217 826 481 553 117 1215 565 1394 735 863 203 1021 284 1294 339 669 982 1023 768 1185 698 1355 963 985 670 1339 1014 1359 397 1197 886 934 180 826 373 1212 441 603 973 1474 1039 1463 1095 1181 947 957 427 1488 263 1157 805 1218 387 451 336 1154 949 973 48 540 68 159 225 1240 335 553 1182 1390 283 1170 317 1469 333 672 433 1260 371 1237 714 727 46 1031 201 1412 125 394 490 1457 324 681 6 203 286 773 847 1166 1346 1480 829 977 89 970 268 945 922 1058 542 1192 34 380 35 247 764 814 470 1364 85 94 31 1432 1274 1367 340 1187 926 969 439 497 961 1026 154 1049 735 742 65 149 265 1054 895 1225 1303 1305 1134 1159 658 1176 198 12…
Output: 344

Constraints:

1 <= n <= 1655; 0 <= m <= 3310; 1 <= u,v <= n.

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