CT48465

Wamika's Ancient Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the cliffside roost of Stormrest, Wamika the clerk keeps careful count of the roads. Prepare the winter inventory, every figure matters. 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 <= 3587; 0 <= m <= 7174; self-edges make the answer NO.

Example 1:

Input: 3532 1216 565 795 1759 2754 1191 3415 481 589 2299 3485 1107 2667 459 2300 171 2837 1309 3395 881 1679 922 2938 1287 3328 935 2145 1368 2363 984 3388 2837 3044 684 2480 1448 2899 2035 2094 1846 3322 1099 1929 913 1325 2208 2234 552 2153 258 1305 1455 3254 490 1581 1564 2608 1473 2722 2982 3322 1421 1913 1731 2504 898 1452 948 1745 797 1881 332 579 11 118 300 2327 655 2145 789 2991 1178 2437 2207 3301 131 2219 1991 3080 652 1311 221 1612 20 2923 887 1992 1757 3426 2512 3414 1378 2587 207 1217 512 1365 2029 2478 1359 2161 1861 3166 2191 2879 143 3441 160 2559 1151 2544 2562 3033 2432 3014 1491 1992 1052 1149 1206 1679 1805 3103 658 759 796 1740 557 1965 993 1500 1368 2008 952 1509 1585 3154 1209 2299 20 2820 2721 3212 1938 2871 1212 2846 42 3250 697 706 129 2924 835 1803 268 2185 106 2251 81…
Output: NO

Example 2:

Input: 2293 3841 1 2 2 3 1 3 922 2132 98 1667 768 2127 74 2110 653 1718 358 1963 555 1447 1131 1990 73 621 152 1182 909 1989 740 1287 588 2285 1235 1877 1736 2027 2183 2197 1669 2086 1957 2006 788 2204 153 609 459 1142 1165 2202 1453 2154 1159 1790 784 1418 217 1371 935 1405 317 1871 928 1373 1494 1911 1106 2107 14 27 1205 1325 1196 2133 407 1525 611 1950 1716 2293 767 2256 411 1222 600 1141 1543 2084 2009 2017 2032 2131 1 1240 331 1726 530 1362 1381 1878 753 1717 314 1614 1941 1955 428 1122 218 2269 396 1194 1092 1448 141 1768 151 297 93 738 544 1949 773 1166 242 873 2129 2277 858 1616 296 1327 994 1315 1102 1720 800 1801 1186 1997 489 2263 30 1481 1607 1658 727 1468 260 1206 1654 1682 23 570 127 1550 921 1047 237 812 361 1703 1660 2112 732 2266 838 1744 1706 2013 824 827 479 874 1559 1724 874 2…
Output: NO

Example 3:

Input: 1393 6174 512 937 563 960 406 1341 180 259 63 1360 273 708 29 963 172 1161 864 1115 436 786 200 756 1120 1393 1009 1147 498 944 249 571 292 1333 391 406 143 1286 30 350 85 834 413 1100 378 911 1098 1284 933 1336 402 1313 312 1305 637 650 1027 1049 870 1044 13 221 494 778 510 727 98 405 1269 1274 50 1055 179 427 428 1165 1146 1210 565 1328 645 958 940 1127 678 751 303 666 2 1079 311 1331 425 1191 994 1049 1025 1281 1129 1229 233 499 525 842 723 985 1015 1029 351 1242 662 1291 837 1183 428 700 242 1222 793 1060 421 1026 751 1191 224 291 625 1321 679 759 364 678 575 929 187 890 477 1323 731 1308 15 1260 266 818 520 1308 194 1356 910 1329 732 1125 554 848 217 1026 122 1298 215 1013 1068 1138 82 587 435 1196 402 542 377 664 824 985 50 524 839 1089 628 780 2 565 5 345 1263 1322 426 1255 1166 129…
Output: NO

Constraints:

1 <= n <= 3587; 0 <= m <= 7174; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Wamika's Ancient Ledger - MEDIUM Coding Problem | CodeTikki