CT40884

The Two Guilds of the Ivory roads

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the fox den of Rustwood as Peddler unrolls the day's manifest of roads. The tally will decide the next shipment. 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 <= 2997; 0 <= m <= 5994; self-edges make the answer NO.

Example 1:

Input: 1110 2575 1 2 2 3 1 3 94 693 358 789 776 869 289 336 473 834 138 866 16 787 919 985 580 618 806 857 570 741 307 743 344 938 80 288 906 1046 413 436 195 308 766 942 446 596 709 906 101 667 7 344 106 328 298 807 1063 1069 254 1060 375 702 893 910 750 905 182 1031 354 776 185 1110 56 867 724 1058 138 1064 98 931 89 411 438 1048 85 842 133 849 662 740 1020 1084 229 251 718 862 47 765 520 820 15 221 204 431 466 713 470 823 312 394 900 1084 327 926 580 685 357 385 457 645 479 941 508 845 549 759 462 521 88 840 139 355 61 950 78 733 249 1066 58 246 14 510 230 1083 174 826 721 1010 59 854 361 901 8 47 109 582 72 719 505 823 24 107 586 1066 418 1100 448 889 737 1067 260 573 22 644 366 752 872 911 357 795 279 280 223 848 97 816 74 963 192 1058 79 827 667 975 447 545 262 285 559 701 929 1012 537 1075…
Output: NO

Example 2:

Input: 2903 5133 1304 2018 758 2041 1406 1698 201 1069 1191 2514 1668 2524 2176 2769 135 1053 1126 2697 437 1068 1093 2306 435 1709 2082 2424 273 518 828 1839 211 1581 1245 1839 1668 2531 1884 1906 1121 2565 1579 1903 2033 2606 1189 2292 1352 1457 1843 2604 769 2736 1620 1663 2102 2469 1790 2526 910 2463 904 1824 665 1674 1211 2350 669 2608 1492 2704 1336 2657 86 1184 1548 1862 394 2773 66 245 1745 2839 813 2610 850 1305 866 1996 977 2786 218 452 473 2092 609 2219 313 2220 637 1407 968 1599 2066 2128 2781 2845 737 2696 236 994 194 579 47 2349 432 1403 2347 2364 480 1987 1003 1643 1749 2338 872 1702 1725 1732 909 1854 1499 1631 538 2075 2018 2412 277 2296 1377 1539 401 2180 1474 2740 550 1492 765 2286 709 2594 1302 1714 152 1786 512 670 728 2732 711 2008 1386 2859 1663 2724 427 2084 529 2858 754 1…
Output: NO

Example 3:

Input: 17 76 5 6 4 5 1 10 8 12 2 7 5 10 8 10 6 17 6 11 3 4 1 2 3 8 9 15 9 16 14 15 9 13 1 7 3 11 1 13 5 15 5 12 6 9 12 16 1 16 8 15 10 15 7 12 2 9 8 11 13 16 4 8 5 7 7 13 1 3 1 15 7 11 7 10 8 9 13 17 4 7 12 17 1 5 2 6 3 5 5 9 1 6 12 15 3 14 4 13 1 11 6 16 11 14 2 4 6 15 4 9 2 5 2 10 10 13 3 12 5 14 4 14 10 14 6 8 5 16 6 14 11 16 3 17 13 15 3 16 7 16 3 15 8 17 2 11 4 6 6 7 4 17
Output: NO

Constraints:

1 <= n <= 2997; 0 <= m <= 5994; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The Two Guilds of the Ivory roads - MEDIUM Coding Problem | CodeTikki