CT57825

The Two Guilds at Stormrest

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Peddler inherited the exchange at the cliffside roost of Stormrest along with its curious bookkeeping system for canals. Time to make sense of it. 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 <= 2497; 0 <= m <= 4994; self-edges make the answer NO.

Example 1:

Input: 1809 1966 59 405 288 1124 364 1279 1460 1480 1093 1426 236 669 27 75 238 764 817 922 242 1297 318 1601 972 1802 365 512 456 1163 660 1368 964 1448 259 600 1480 1652 161 607 706 1515 132 564 1204 1231 1161 1615 1568 1736 1430 1445 501 1019 395 421 846 1116 666 839 661 1487 578 1667 857 1644 695 1540 1203 1538 501 550 215 768 293 713 681 1268 196 1463 1426 1493 129 153 965 1005 1521 1525 2 211 430 1659 271 1016 520 821 360 374 248 1577 749 993 264 499 834 1658 671 1324 816 1540 161 1421 1669 1804 1116 1119 416 523 1410 1696 243 1630 1503 1510 415 1036 1670 1744 521 717 142 542 627 753 284 314 36 1172 348 646 873 1261 307 902 771 1506 920 1519 644 835 3 1388 941 997 1009 1544 1369 1766 471 830 138 1614 922 1794 816 1805 417 1540 421 1682 999 1140 1056 1796 1452 1569 457 1158 916 1494 773 1418…
Output: NO

Example 2:

Input: 2256 666 998 1123 24 1385 426 2083 1393 2184 153 1503 714 2082 249 526 1862 1980 374 1148 631 674 344 781 1052 1988 572 1244 222 1276 287 1008 411 1134 1329 2080 1269 1628 1036 1348 565 1255 703 2117 875 2167 46 1387 167 1096 668 2106 196 1266 332 1358 815 1991 1253 1456 473 1881 1133 1839 449 2003 836 2148 1092 1216 522 1569 1795 1818 28 947 1081 1750 264 676 1723 1787 812 1697 995 1700 172 1126 894 1572 1159 1176 1287 1610 168 987 1015 1353 1176 1454 1208 1273 1141 1388 780 944 719 1985 1898 1964 1526 2245 110 216 1524 1803 1298 1888 1881 2230 576 1566 1678 1990 1004 1705 538 1057 189 1673 419 748 973 1670 1231 1597 1709 1839 382 1447 453 705 222 1797 376 1214 1823 1894 381 1811 345 1806 534 579 1637 1967 275 1755 291 1602 1355 1615 1246 1336 202 721 1003 1064 986 1309 102 1984 657 1662 …
Output: YES

Example 3:

Input: 1785 4383 841 1418 727 967 350 1025 361 1067 461 1666 629 1168 641 1200 430 1692 108 1207 214 224 200 1355 322 1632 419 1544 42 1004 566 647 1058 1274 1192 1559 621 1095 921 1310 3 918 360 376 14 422 192 683 1081 1440 106 941 379 1366 1127 1550 422 1239 1097 1741 693 1740 106 1040 92 450 884 1730 698 710 306 1277 283 1046 467 482 296 1199 154 242 795 1395 819 1269 20 149 412 1549 1282 1772 345 1055 634 781 87 1001 8 173 653 960 114 534 1027 1253 192 629 602 1543 1232 1319 1499 1542 54 924 129 662 1004 1678 568 1272 634 1033 436 473 1051 1619 85 857 15 1633 534 1538 1106 1395 93 256 407 1698 17 848 244 864 188 821 999 1093 306 1705 236 745 214 618 913 1066 1430 1502 743 1170 204 1585 404 1282 1067 1123 1438 1759 398 447 776 1545 215 1611 138 624 1303 1498 289 1610 310 1141 149 562 240 641 5…
Output: NO

Constraints:

1 <= n <= 2497; 0 <= m <= 4994; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The Two Guilds at Stormrest - MEDIUM Coding Problem | CodeTikki