CT41549

Corwin's Two Guilds Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The quartermaster Corwin has been asked to approve the repair estimates. On the desk lies a long table of corridors readings. 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 <= 2967; 0 <= m <= 5934; self-edges make the answer NO.

Example 1:

Input: 1422 4253 1 2 2 3 1 3 819 844 220 1103 778 1008 246 1311 871 913 731 1036 621 856 406 778 130 747 366 1035 913 1274 592 994 212 364 536 821 483 562 489 1407 822 1123 276 957 149 365 572 661 31 1350 955 1180 295 953 993 1072 1176 1310 910 1395 334 779 72 250 72 75 862 1268 483 955 145 1038 91 974 832 1032 185 1003 872 907 830 1182 799 940 170 676 154 966 300 1052 493 650 36 91 809 1007 1118 1201 43 740 498 1344 209 1284 674 847 317 1154 84 818 340 897 901 940 564 1299 429 462 40 810 742 1290 118 510 959 1382 252 1112 434 707 147 332 985 1325 334 934 280 1233 1058 1248 555 1289 932 1227 29 886 142 370 44 1376 294 517 405 857 3 28 1016 1082 729 1344 1107 1217 438 1198 629 1325 326 712 42 301 411 754 119 1371 14 107 173 1406 44 839 312 825 620 1207 62 233 226 520 255 1125 994 1357 281 604 840 …
Output: NO

Example 2:

Input: 2450 3450 2068 2149 1040 1101 1993 2131 373 1134 1698 1821 1377 2412 1189 1237 867 1644 1359 1758 702 1470 1204 1789 1306 1368 271 1924 1369 1399 63 855 649 1241 1070 2422 1259 1484 100 835 977 1707 401 1586 481 1589 546 576 1042 2062 349 1318 1518 1909 1249 2041 1795 2279 1292 1955 523 1165 77 1039 1679 1786 454 808 1302 2419 183 2413 1033 2416 700 1655 1282 1691 2046 2136 571 2318 52 1090 928 2085 1866 2178 706 896 85 2412 1466 2167 69 2272 246 1921 226 401 881 1138 360 2324 371 1324 120 1838 1175 2301 1318 1660 1562 1882 85 1583 1455 2054 2274 2313 386 1680 2107 2398 960 1192 80 2101 105 921 757 1459 1385 1391 1418 2088 621 2435 1434 1949 135 1572 1929 2196 947 1174 780 2449 1690 1951 1038 1103 1421 1969 1436 1703 531 1884 2083 2313 110 522 1282 1585 2201 2323 1770 2378 862 934 489 1887…
Output: NO

Example 3:

Input: 1462 5019 284 1267 1080 1131 562 1099 2 1421 872 1268 19 533 298 1176 777 1307 373 1192 257 1183 66 970 361 995 233 1184 503 641 127 623 294 806 684 1166 842 903 150 556 304 643 866 1076 311 723 503 583 213 1384 73 1348 427 617 1132 1413 57 927 853 1456 492 1267 335 1143 466 614 930 1287 454 819 1286 1369 677 945 588 1357 98 1455 826 1305 458 1443 204 614 225 361 771 1173 211 1230 456 1139 795 1254 625 684 436 455 290 489 1048 1156 82 1311 1270 1363 250 666 1270 1277 469 866 1011 1056 552 840 719 1095 995 1195 153 1344 600 1110 375 406 125 520 981 1456 235 836 38 822 573 969 4 651 771 1105 136 1004 913 1396 1289 1311 350 655 340 997 35 900 149 649 1223 1249 534 1028 205 837 215 829 109 1124 484 1226 1102 1454 983 1100 432 1043 988 1436 631 667 431 1206 553 1323 928 1021 504 1274 217 1415 1…
Output: NO

Constraints:

1 <= n <= 2967; 0 <= m <= 5934; self-edges make the answer NO.

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