CT52993

Innkeeper's Two Guilds Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Innkeeper inherited the salt store at the honeycomb cliffs of Beeswick along with its curious bookkeeping system for bridges. 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 <= 2683; 0 <= m <= 5366; self-edges make the answer NO.

Example 1:

Input: 2269 4612 534 633 1645 2137 346 1469 33 824 687 1605 1020 1904 420 1635 780 1104 311 731 547 2199 778 1165 70 755 1867 2059 576 2115 1787 1962 368 1271 1611 2079 732 901 1252 1297 158 1766 61 95 124 235 263 2071 495 1382 119 1811 514 1340 1244 1288 915 1316 664 2015 359 852 307 1244 174 1725 140 385 462 2055 19 363 335 825 1645 1946 1940 2113 382 1754 244 1353 1276 1984 1539 1817 1172 1359 242 2053 162 1290 649 1712 1724 1865 634 729 1000 1043 124 1744 951 1521 554 1334 915 1559 232 1057 317 565 169 1174 625 1118 660 1649 1355 2109 417 1847 778 1823 1168 1325 197 1329 502 1484 1102 1193 1502 1603 1263 1706 338 1742 311 557 508 1156 787 2265 751 2085 991 2127 222 1768 1896 2235 519 2195 876 1582 535 1161 1936 2217 242 1713 1079 1696 1881 1889 1393 1950 1100 1677 650 1910 694 2203 1014 2117 …
Output: NO

Example 2:

Input: 1475 4713 1 2 2 3 1 3 379 569 306 365 294 689 1136 1277 34 462 28 122 193 214 1070 1185 140 416 1080 1343 53 980 1389 1428 1 1409 659 1318 282 623 719 1414 243 1003 799 1403 484 1288 183 916 254 551 715 788 217 301 1305 1451 72 902 263 472 74 1068 58 958 1249 1378 928 1396 568 1175 743 820 434 821 17 281 234 380 448 1111 31 401 1393 1430 297 1331 255 886 83 435 1232 1380 465 814 659 964 1263 1268 225 835 30 1450 1353 1408 335 532 916 1211 8 413 336 797 187 947 62 1158 150 450 384 1432 1326 1414 640 683 640 812 449 1047 210 311 1252 1265 855 1138 8 608 567 1449 961 1350 60 1370 404 825 219 634 250 1004 1098 1301 24 492 334 511 79 1277 238 1203 1008 1164 667 1474 1165 1171 506 828 44 1045 1204 1302 330 732 628 673 565 991 642 1363 1011 1452 684 707 106 616 336 1062 470 701 165 432 920 1180 8…
Output: NO

Example 3:

Input: 981 1034 490 873 210 885 215 275 118 388 158 334 54 688 134 708 52 735 81 893 90 127 147 326 646 963 555 655 794 843 783 797 409 520 523 811 51 630 210 544 135 627 529 636 96 325 80 726 630 948 712 757 120 608 28 45 775 898 303 823 19 92 149 379 167 614 554 646 516 885 575 817 175 256 277 628 101 770 349 876 175 729 370 712 770 841 25 164 385 577 22 929 272 845 16 204 355 816 5 151 141 635 428 952 232 383 481 981 14 43 340 808 366 420 230 654 841 942 167 250 284 652 124 302 45 450 78 262 576 683 648 963 356 656 337 702 221 353 821 884 32 684 42 889 312 602 413 798 7 241 454 830 324 933 448 739 143 419 35 604 319 878 286 404 604 754 206 426 408 510 271 560 611 903 48 348 71 873 116 721 154 877 741 751 269 846 477 898 153 357 350 556 102 215 313 509 137 649 4 181 112 757 142 223 394 858 423 …
Output: NO

Constraints:

1 <= n <= 2683; 0 <= m <= 5366; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Innkeeper's Two Guilds Ledger - MEDIUM Coding Problem | CodeTikki