CT54983

Freya Counts the canals

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the boar woods of Tuskmore; Freya weighs the day's canals manifests and starts the calculations. Task: Print YES if the undirected graph's nodes can be split into two groups with no edge inside a group, otherwise NO. Input format: First line: n and m. Next m lines: u v. Output format: Print YES or NO. Constraints: 1 <= n <= 2984; 0 <= m <= 5968; self-edges make the answer NO.

Example 1:

Input: 1387 2736 1 2 2 3 1 3 96 934 938 1376 46 1113 786 1125 665 894 405 1020 488 821 16 46 742 964 86 1357 434 602 221 527 702 1124 178 517 600 769 97 1293 137 1028 362 620 587 1225 593 805 754 916 217 952 786 994 374 1297 933 1306 900 992 247 979 107 526 1010 1242 70 249 694 1231 187 715 281 1325 151 404 659 1024 849 1050 1 986 889 951 986 1023 120 1026 546 1266 980 1050 44 1038 1176 1386 297 1026 508 1306 369 727 944 945 1168 1300 1255 1349 713 1201 130 664 372 1126 412 1125 176 373 320 945 894 1076 526 1113 121 739 212 338 419 1139 303 806 26 960 1017 1381 237 448 1206 1294 522 833 944 1253 32 1310 878 898 603 826 779 876 1077 1205 240 1229 242 851 559 955 618 1054 457 793 394 782 338 484 251 718 1087 1279 1200 1327 782 1083 84 580 795 836 243 1329 776 1251 859 1299 118 531 134 1022 131 258 …
Output: NO

Example 2:

Input: 105 1958 22 55 26 61 29 103 5 91 11 65 13 54 38 104 4 36 72 77 37 89 5 27 47 67 7 74 19 53 31 48 64 97 11 92 62 87 21 61 19 26 33 65 3 44 31 32 69 97 44 99 66 72 28 37 59 67 19 98 15 105 35 53 40 101 17 63 11 86 45 101 21 94 45 84 73 93 77 78 60 103 6 21 42 101 36 55 5 101 41 82 46 100 26 89 4 34 19 94 16 71 23 77 12 77 47 51 37 90 4 8 61 76 40 87 46 79 25 89 15 53 53 95 64 94 90 98 28 46 14 70 58 79 6 16 16 27 15 58 52 58 6 87 61 98 62 97 4 96 39 99 27 72 50 64 39 61 55 105 26 62 74 101 32 42 40 52 33 97 30 93 26 80 19 83 47 105 17 34 25 42 53 81 68 76 54 94 36 44 19 24 88 93 29 31 7 16 16 105 30 58 13 61 4 7 51 94 51 61 30 101 49 64 40 54 32 66 64 91 38 97 21 93 9 69 60 72 38 41 79 94 10 47 49 55 22 40 27 90 18 71 54 60 92 100 14 20 5 21 25 30 50 76 12 16 33 41 85 101 53 76 37 46 6 27 45…
Output: NO

Example 3:

Input: 14 72 7 9 4 6 1 7 1 3 2 13 1 14 5 8 5 9 3 9 4 11 5 11 3 7 10 11 6 8 4 9 3 6 2 6 2 8 9 14 6 7 6 10 8 9 3 11 3 5 8 11 6 13 11 12 4 13 4 5 7 12 11 13 4 12 9 11 1 12 2 5 2 3 2 9 12 14 2 4 6 12 1 6 13 14 10 13 12 13 10 12 7 8 4 8 6 9 6 11 9 13 1 9 7 13 5 12 8 14 8 12 7 14 1 10 8 13 6 14 2 10 4 14 1 4 1 2 5 14 1 11 3 13 5 13 5 7 1 5 7 10 4 10 3 14
Output: NO

Constraints:

1 <= n <= 2984; 0 <= m <= 5968; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Freya Counts the canals - MEDIUM Coding Problem | CodeTikki