CT60062

Last canals of Aldo

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the poppy fields of Scarlet Plain close for winter, Aldo must finish the canals ledger - one figure at a time. 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 <= 2087; 0 <= m <= 4174; self-edges make the answer NO.

Example 1:

Input: 348 394 1 2 2 3 1 3 43 62 194 216 229 233 261 347 75 132 41 267 269 319 110 348 60 326 61 175 37 108 189 231 44 95 125 325 58 307 105 235 3 145 302 313 50 244 62 234 31 264 63 154 298 321 29 138 199 317 1 64 17 218 91 138 74 83 180 282 5 40 264 273 174 238 23 151 35 37 241 346 41 74 47 126 138 187 94 324 276 336 84 89 213 241 49 146 138 166 121 148 41 204 286 330 85 282 155 179 14 311 192 279 77 186 197 274 183 310 11 295 7 211 32 228 111 322 19 115 40 67 27 211 223 260 4 333 210 289 38 119 219 261 73 317 153 331 205 325 111 298 32 127 10 207 234 330 81 199 242 348 100 283 177 244 232 315 78 84 87 101 72 106 239 260 70 220 53 139 89 148 84 323 243 246 29 238 49 333 197 288 91 243 147 258 128 177 206 312 34 100 260 340 73 246 283 327 197 241 85 309 286 334 120 263 5 88 190 317 88 148 205 33…
Output: NO

Example 2:

Input: 2042 2186 230 2009 1053 1739 1496 1765 616 1555 1446 1979 1164 1324 1307 1333 597 1278 1174 1434 108 1351 802 1246 265 1063 890 1118 471 699 469 1388 317 1076 1057 1536 1609 1754 1753 1787 168 1462 418 449 1243 1837 137 1659 1560 1624 689 1770 869 1228 943 1696 301 1174 652 1874 146 1170 1526 1693 546 1442 508 1395 1500 1887 1179 1356 1537 1721 1068 1310 1404 1895 293 653 1045 1078 111 1343 786 1867 196 1205 1446 1861 771 1419 653 1875 797 1493 171 1088 587 1980 558 2040 699 1854 443 963 408 1107 224 382 1868 1884 995 1772 690 1810 633 1012 919 2002 1382 1840 244 573 1586 1846 37 392 344 1884 217 820 943 1059 1057 1784 202 1426 854 1601 232 1307 1771 1979 10 898 877 1978 385 2030 559 1066 482 487 204 553 1638 1948 103 1495 547 1671 1488 1625 1159 1857 1699 2030 1147 1151 1704 1890 148 1545…
Output: NO

Example 3:

Input: 1195 2 466 1040 94 965
Output: YES

Constraints:

1 <= n <= 2087; 0 <= m <= 4174; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Last canals of Aldo - MEDIUM Coding Problem | CodeTikki