CT50456

The Two Guilds of Amberfield

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the wheat plains of Amberfield pays by the answer, and Chavi intends to earn it. First: the full register of roads. 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 <= 2850; 0 <= m <= 5700; self-edges make the answer NO.

Example 1:

Input: 62 1234 9 45 49 62 10 18 10 53 1 45 12 56 46 61 5 59 18 38 16 53 5 54 7 57 30 33 30 52 30 57 21 52 26 29 3 42 21 49 5 46 44 60 40 52 18 39 27 31 14 37 3 21 31 39 1 47 34 37 9 58 3 26 2 7 35 47 14 42 7 9 33 62 8 38 2 40 6 62 57 58 36 54 2 56 24 47 41 62 1 62 5 13 24 53 16 56 19 25 2 29 10 61 14 29 21 39 2 10 16 58 23 41 17 33 34 52 19 57 53 62 5 48 18 20 22 24 9 24 39 56 29 41 32 51 25 32 8 62 46 47 29 61 41 43 18 23 43 54 16 43 20 30 42 60 1 8 16 50 15 59 52 58 12 23 21 47 34 50 19 30 20 26 15 41 4 28 39 51 25 42 32 55 11 60 27 61 10 19 23 35 29 47 21 48 4 22 22 29 18 56 34 36 11 25 11 43 16 44 31 38 37 41 34 58 44 53 42 59 7 30 37 58 35 54 37 54 17 30 4 32 27 30 43 60 37 56 10 36 43 57 25 52 34 53 36 37 12 28 17 23 3 4 6 23 23 46 17 43 39 48 20 59 9 25 34 41 3 6 13 49 28 52 1 19 18 55 35 …
Output: NO

Example 2:

Input: 1797 2474 1 2 2 3 1 3 994 1488 164 1036 794 1044 712 967 556 1741 1544 1638 123 1725 998 1462 595 1756 650 1457 1003 1638 693 1736 665 1796 325 1612 843 1490 404 1568 1419 1457 85 269 388 543 366 497 930 1028 123 1308 427 1270 893 1177 74 762 1139 1525 53 1204 525 1352 172 509 997 1407 391 738 267 898 821 1675 870 1319 929 1262 87 234 377 564 261 1139 713 1067 607 854 194 325 1021 1196 322 1253 26 756 394 702 120 1053 1295 1475 1062 1143 1162 1580 1411 1477 1561 1640 472 1187 647 679 385 1001 197 444 56 1388 884 1530 574 722 291 1361 813 1773 1114 1634 242 1078 532 596 3 1490 1174 1367 677 1696 1024 1209 6 105 336 1068 438 812 772 1539 74 275 855 1658 1182 1766 1109 1722 1023 1710 145 744 936 975 1365 1511 1295 1629 179 949 418 1043 7 215 228 860 1039 1409 1113 1703 1153 1573 929 1046 449 …
Output: NO

Example 3:

Input: 2564 2729 1 2 2 3 1 3 1420 2074 1178 2404 509 2004 1164 1386 596 1627 222 1833 735 1728 230 1730 195 1210 861 1646 709 2502 289 2113 1309 1889 1140 1549 459 1878 157 958 855 2246 99 141 105 2503 979 1587 1268 1792 622 761 688 1282 136 2431 43 1632 400 883 347 703 373 1250 515 1916 440 656 309 2412 1572 1586 830 1670 2030 2415 17 627 731 2379 1480 1486 606 972 350 2504 366 2081 1722 2426 588 1755 471 1967 553 913 2107 2505 1934 2266 32 858 103 2404 520 1416 1001 1523 593 1809 1877 2008 1888 2220 1596 2148 987 1402 807 1837 35 2406 180 883 309 1701 1910 2059 713 1669 221 806 194 1784 294 915 51 1758 457 537 178 2219 404 511 366 1295 1724 2057 266 1886 576 1435 684 844 110 1450 569 1250 497 580 717 1414 282 2183 60 279 1538 2142 199 2196 1224 1952 358 1206 245 977 1654 1795 103 1876 1786 1855…
Output: NO

Constraints:

1 <= n <= 2850; 0 <= m <= 5700; self-edges make the answer NO.

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