CT54969

Squire's Ivory Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the floating docks of Skyharbor. Squire spreads the corridors records across the table and picks up a sharp pencil. 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 <= 2704; 0 <= m <= 5408; self-edges make the answer NO.

Example 1:

Input: 85 510 2 71 25 36 6 66 8 58 41 57 19 22 48 62 45 74 18 85 38 69 38 83 18 72 52 58 10 44 3 17 63 68 24 48 52 69 2 55 49 82 9 42 56 81 65 80 50 80 8 35 5 30 38 65 69 75 39 54 16 43 12 34 3 10 15 17 50 74 32 40 25 50 17 42 47 73 11 59 2 74 15 45 16 63 35 51 15 30 9 39 25 64 26 49 60 77 8 62 39 53 64 83 4 60 3 69 34 61 38 55 46 75 51 60 22 45 55 77 39 58 16 77 42 62 12 67 1 66 1 21 38 51 66 82 17 65 6 32 4 13 52 79 7 70 58 60 66 71 6 28 13 79 44 64 41 71 36 55 4 73 11 37 30 77 9 64 33 84 16 64 30 70 38 41 52 80 39 48 28 80 6 29 27 59 4 58 5 65 47 49 17 26 55 57 35 38 35 43 19 57 14 79 26 78 20 82 29 53 35 45 48 77 16 59 19 77 1 39 72 78 30 40 22 60 34 67 4 67 17 68 22 51 3 50 36 62 23 30 27 33 5 71 48 66 17 46 35 73 22 74 62 63 38 64 70 71 23 34 19 64 9 62 25 45 18 20 78 83 10 15 1 62 21 24 22…
Output: NO

Example 2:

Input: 194 3468 163 180 68 154 4 51 53 185 2 55 67 71 59 65 20 185 40 130 60 84 8 17 7 129 31 114 3 93 123 159 8 154 26 88 75 109 77 170 53 121 1 120 1 84 62 81 36 182 27 95 8 121 5 175 6 160 22 125 6 130 76 170 86 106 39 128 150 171 24 174 57 178 124 126 23 92 41 149 59 117 31 107 128 177 86 141 79 190 84 182 47 140 106 171 11 183 53 127 69 120 109 134 13 118 28 177 52 67 114 136 167 188 82 114 65 159 104 131 106 156 90 194 38 58 102 126 29 69 87 187 124 147 73 167 26 69 27 132 79 132 151 187 18 88 21 122 108 110 19 59 131 143 64 121 72 105 58 181 43 174 2 11 41 139 20 45 166 190 24 156 27 165 3 178 129 176 52 132 20 25 132 189 123 162 113 164 4 84 110 121 18 138 28 192 17 161 24 136 96 108 35 175 178 180 33 50 137 170 67 104 110 169 53 193 127 160 83 194 102 130 141 178 30 67 191 194 40 104 24 …
Output: NO

Example 3:

Input: 2056 4145 1570 1757 182 721 1069 1169 66 851 110 955 83 1856 83 1749 620 1653 582 628 1107 2050 158 377 18 1811 228 996 109 789 357 1880 500 1368 1137 1278 1176 1761 729 759 10 1618 26 652 207 1253 340 1247 91 265 848 892 214 887 104 1583 654 1278 211 1340 385 1288 1046 1505 1271 1700 594 699 201 1507 1641 1685 945 1883 291 1471 345 1144 303 1633 991 1946 219 850 50 1638 1515 1759 1391 1981 1096 1759 535 2042 488 753 5 1498 333 1490 1131 1961 1568 2000 350 1193 739 1622 872 1633 53 1940 1242 1819 287 673 766 1376 172 1010 503 1594 528 1960 1132 1167 430 1280 22 718 196 1496 1479 1892 474 1577 422 480 708 855 272 1423 1457 1519 676 1474 98 1663 74 180 412 1987 1411 1799 1150 1715 1074 1204 287 289 1856 1859 44 525 1443 1455 382 1708 1672 1804 828 1990 1279 2007 1257 1961 742 1126 1688 1956 …
Output: NO

Constraints:

1 <= n <= 2704; 0 <= m <= 5408; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Squire's Ivory Ledger - MEDIUM Coding Problem | CodeTikki